views:

19

answers:

1

I have an image displayed using CGRect (code below). the problem is that it's obscuring UIButtons I have in the nib file.

CGRect myImageRect = CGRectMake(0.0f, 40.0f, 480.0f, 280.0f);
UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
[myImage setImage:[UIImage imageNamed:recipe.image]];
[self.view addSubview:myImage];
[myImage release];

if I make the CGRect smaller, the UIButtons are there. I can't figure out how to fix this, any help is very appreciated.

thanks

+3  A: 

You need to send your subview to the back:

[self.view sendSubviewToBack:myImage];
Peter DeWeese
I tried that and the image is hidden from view. all that's shown is the UIView background set in IB.
hanumanDev
Hmm, and of course you need to call it after adding it to the view, not before. Where is the code above located? Is it after the nib is initialized? Also, is "self" the controller for the root of the nib or for some subview within it?
Peter DeWeese
the code is in the - (void) viewWillAppear method.I'm not sure how to answer your other questions though, i'm new at this.
hanumanDev
I realized that I was replacing the [self.view addSubview:myImage];w/ the code you posted. instead I added it like so:[self.view addSubview:myImage];[self.view sendSubviewToBack:myImage];it works great, thanks a lot!
hanumanDev
np! How bout accepting the answer? :-)
Peter DeWeese