sendSubviewToBack hides UIImageView
I have an UIImageView and a few buttons defined in interface builder. I want to display an image with the buttons on top of it. I add an image to the UIImageView programatically but it covers up the buttons. I tried using sendSubviewToBack and the image disappeared completely. Here's my code
UIImageView *imageView = [[UIImageView allo开发者_如何学Pythonc] initWithFrame:
CGRectMake(0.0, 0.0, 320.0, 480.0)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"mypic%d.png", index]];
[self.view addSubview:imageView];
[self.view sendSubviewToBack:imageView];
[imageView release];
Please help.
ok, i'm a newbie and I was dumb. I was defining a UIImageView on interface builder and also in the code thus hiding one behind another. sorry.
You might also choose to simply create the image view in Interface Builder, create an outlet to it, then set the image programmatically. Doesn't look like you need to dynamically mess with the view hierarchy here.
精彩评论