Questions tagged [subview]

subview is an abstract representation of a nested hierarchy of views in a MVC framework

A subview can be defined either explicitly as a separate class, or implicitly via object composition, depending on the framework.

References

1264 questions
331
votes
15 answers

How to remove all subviews?

When my app gets back to its root view controller, in the viewDidAppear: method I need to remove all subviews. How can I do this?
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
144
votes
4 answers

How to add a Container View programmatically

A Container View can be easily added into a storyboard through Interface Editor. When added, a Container View is of a placeholder view, an embed segue, and a (child) view controller. However, I am not able to find a way to add a Container View…
Dante May Code
  • 11,177
  • 9
  • 49
  • 81
94
votes
22 answers

How to list out all the subviews in a uiviewcontroller in iOS?

I want to list out all the subviews in a UIViewController. I tried self.view.subviews, but not all of the subviews are listed out, for instance, the subviews in the UITableViewCell are not found. Any idea?
user403015
  • 7,209
  • 19
  • 66
  • 100
88
votes
4 answers

Difference between addSubview and insertSubview in UIView class

What is the difference between addSubview and insertSubView methods when a view is added programmatically?
Ashwani K
  • 7,880
  • 19
  • 63
  • 102
87
votes
18 answers

How can I loop through all subviews of a UIView, and their subviews and their subviews

How can I loop through all subviews of a UIView, and their subviews and their subviews?
123hal321
  • 2,080
  • 4
  • 24
  • 25
64
votes
8 answers

Bringing a subview to be in front of all other views

I am working on integrating an ad provider into my app currently. I wish to place a fading message in front of the ad when the ad displays but have been completely unsuccessful. I made a function which adds a subview to my current view and tries to…
Mark S
  • 2,161
  • 3
  • 21
  • 25
63
votes
12 answers

Swift: Get all subviews of a specific type and add to an array

I have a custom class of buttons in a UIView that I'd like to add to an array so that they're easily accessible. Is there a way to get all subviews of a specific class and add it to an array in Swift?
Kenji Crosland
  • 2,914
  • 6
  • 31
  • 40
62
votes
4 answers

Scale UIView and all its children

I have an UIView with around 50 UIButtons. All button positions were given in pixels, relative to the left upper corner of my main UIView. All (background) images used in the view are available in higher resolution. As I am porting my app from…
andreas
  • 7,844
  • 9
  • 51
  • 72
57
votes
4 answers

Apple Interface Builder: adding subview to UIImageView

I created UIImageView with the help of Interface Bulder. Now I want to place label inside it (as its subview). In code I can type something like: [myUIImageView addSubview:myUILabel]; But can I do it with the help of IB? I found the solution for…
kpower
  • 3,871
  • 4
  • 42
  • 62
55
votes
7 answers

add UIImage in CALayer

I must add a UIImageView as subview of MapView. To do this I created a layer above the MapView. In this layer I want to put my image, but I get a white rectangle and nothing else. My image is not visible. This is the code: - (void)viewDidLoad { …
Ortensia C.
  • 4,666
  • 11
  • 43
  • 70
53
votes
1 answer

When to use f:view and f:subview

I am not sure what are the benefits of using and . I noticed that one could write JSF pages without using them. What are the benefits of using those tags?
Nick
  • 629
  • 1
  • 6
  • 9
45
votes
10 answers

UICollectionView cell subviews do not resize

In a CollectionView, some cells should have an additional subview or layer. The CollectionView can be told to resize it's cells, thus all content needs to resize appropriately. Currently, the cell is initialized from a nib containing a cell with…
ceekay
  • 1,167
  • 1
  • 10
  • 14
42
votes
11 answers

Cannot put a google maps GMSMapView in a subview of main main view?

I'm struggling with this problem! I want to add a google maps GMSMapView into a UIView that is only a portion of the main UIView of my ViewController. It should be simple... I created with the storyboard a UIView of the size I want and put it in the…
AndreaZ
  • 461
  • 1
  • 4
  • 5
40
votes
8 answers

What is the correct way to remove a subview from a view hierarchy and nuke it?

I have a parent UIView with a number of subviews. Periodically I need to remove a subview and completely remove it from the system. What is the correct way to do this? I tried this: UIView *v = [self.containerView viewWithTag:[n integerValue]]; [v…
dugla
  • 12,774
  • 26
  • 88
  • 136
39
votes
6 answers

How can I insert a subview below the other subviews

everyone. I have some labels that I draw them in the xib file, and add a background view using codes,but the background view is in the front of these labels, so I cant see them. So, my question is how can I add a background view below…
jxdwinter
  • 2,339
  • 6
  • 36
  • 56
1
2 3
84 85