tags:

views:

29

answers:

2

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 alloc] 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.

A: 

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.

yeti
A: 

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.

Joey Hagedorn