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?
Asked
Active
Viewed 1,791 times
1
-
Are you sure you don't mean to do it the other way around? (i.e. add the image view as a subview of the scroll view?) – jonkroll Apr 06 '12 at 06:34
-
what is the difficulty you are facing?? – Leena Apr 06 '12 at 06:48
-
possible duplicate question: http://stackoverflow.com/a/2956734/1804403 – Skotch Jul 31 '13 at 01:32
2 Answers
2
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
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
Here you can see a container
UIView
that holds the UIImageView
and another subview

Paul.s
- 38,494
- 5
- 70
- 88
0
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];

Otium
- 1,098
- 8
- 20