将子视图添加到UIImageView,它是IB中UIViewController的视图出口

问题描述:

我在.xib文件中有一个UIViewController对象。我添加了一个UIImageView,然后尝试添加一个按钮作为UIImageView的子视图。它取代了UIImageView。如果两者都是UIView的子视图,它工作正常。是什么赋予了?我认为这可行,因为UIImageView是UIView的子类?

I have a UIViewController object in a .xib file. I add a UIImageView to it, and then try to add a button as a subview of the UIImageView. It instead replaces the UIImageView. It works fine if both are subviews of a UIView. What gives? I thought this would work since UIImageView is a subclass of UIView?

只有Apple知道。

但是,请看这里找一个解决方法:

However, look at here for a workaround:

Apple Interface Builder:将子视图添加到UIImageView