开发者

sendSubviewToBack hides UIImageView

开发者 https://www.devze.com 2023-01-22 04:00 出处:网络
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 b

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号