xonegirlz
xonegirlz

Reputation: 8977

add subview to UIImageView via interface builder

Is such thing possible? I have my UIScrollView created via IB and I wanted it as a subview of a UIImgeView I have, created in IB as well. If it is possible how do I do so?

Upvotes: 1

Views: 1794

Answers (2)

Paul.s
Paul.s

Reputation: 38728

Short answer NO. The workarounds depend on what's more important to you

1. Creating the UIImageView subview hierarchy in the xib is most important

Start with a UIView but change it's class to UIImageView

enter image description here

then set the image in code

self.myImageView.image = [UIImage imageNamed:@"someImage"];

2. Setting the image in the xib is most important

Then do as you have been doing and add the subviews in code

[self.myImageView addSubview:someSubView];

3. You want the imageView and the other view to move and scale in unison

Then place them in a container UIView that is the same size as the UIImageView

enter image description here

Here you can see a container UIView that holds the UIImageView and another subview

Upvotes: 2

Otium
Otium

Reputation: 1098

If you can't drag it into the UIImageView then I do not think it is possible,and an imageViews purpose is not meant to hold subviews. But it is just as easy to add it in code

[imageView addSubview:subView];

Upvotes: 0

Related Questions