views:

768

answers:

4

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?

A: 

Agreed. Not quite sure by what you mean by "send to the back" but here's a guess...

If you are adjusting the layering within your main view, be sure you are not sending a view "to the back" (changing it's layer) that has number of subviews... or else they would all go to the back (their layering would change) at the same time.

If this is totally not what you meant, just let me know, and I'll delete this answer.

mmc
+3  A: 

If you are using UIView's sendSubviewToBack: or a similar message, you probably have your buttons inserted in the heirarchy under the UIIMage view. When a view moves in the heirarchy, all of it's 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 dificult to be more precise.

Roger Nolan
A: 

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

Hans Espen
A: 

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!

Hans Espen