Sending view to back
Solution 1
If you are using UIView
's sendSubviewToBack:
or a similar message, you probably have your buttons inserted in the hierarchy under the UIImageView
. When a view moves in the hierarchy, all of its subviews move with it.
To fix this, you need to add your controls as subviews of the same view (possibly the UIWindow
) you added the UIImageView
to initially.
Without seeing your code, it's very difficult to be more precise.
Solution 2
By not having to add it programmatically and adjust the views, much easier to layer each one in the interface builder. Make sure the image view, if this is set as the background, make sure it is the first to be listed.
Related videos on Youtube
Comments
-
Hans Espen almost 2 years
When I try to send a view to the back, it hides some of the buttons and labels in my view controller. The view I am sending to the back is a UIImageView. Does anyone have an opinion of what might be the problem?
Here is the code I am using:
UIImage *image = [UIImage imageNamed: @"background.jpg"]; UIImageView *backImage = [[UIImageView alloc] initWithImage: image]; [self.view addSubview: backImage]; [self.view sendSubviewToBack: backImage];
Then, when I am adding controls to self.view, they does not always show
I managed to get it roght by moving my code from init to loadView. I don't understand why that should make a difference, but hey.. it works!
-
pgb almost 15 yearsCan you post some sample code?
-
shiva kumar almost 15 yearsnot entirely sure by what you mean 'send to the back'
-