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?
Only Apple knows.
However, look at here for a workaround:
A UIImageView
is it's own object and a UIButton
is its own object. A UIImageView
is an outlet placeholder for an image. If you're trying to add a background image to a button you can use the background image property or if you'd like the background to span beyond the bounds of the button you can drop a UIView
onto IB and style that using code or subclassing UIImageView
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.