Marty
Marty

Reputation: 6174

Add a subview to a UIImageView that is the view outlet of a UIViewController in IB

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?

Upvotes: 3

Views: 5798

Answers (2)

TALLBOY
TALLBOY

Reputation: 1077

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.

Upvotes: 0

user4951
user4951

Reputation: 33050

Only Apple knows.

However, look at here for a workaround:

Apple Interface Builder: adding subview to UIImageView

Upvotes: 3

Related Questions