views:

98

answers:

1

hi,
i want to use an image in a UIButton buttonHeader background,
when i compile it i get an error that buttonHeader is not an image type, what property to use?

- (void)downloadImageHeader
{
    NSMutableURLRequest *requestWithBodyParams = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.../imageHeader.png"]];
    NSData *imageData = [NSURLConnection sendSynchronousRequest:requestWithBodyParams returningResponse:nil error:nil];
    UIImage *image = [UIImage imageWithData:imageData];
    buttonHeader = image;
}
+1  A: 

You should use the UIButton method

- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state

like

[buttonHeader setBackgroundImage:image forState:UIControlStateNormal];
epatel
where is buttonHeader declared here?
suse
@suse I guess it's a UIButton ivar that he uses in the example code. As he writes it's a UIButton in the text above the code.
epatel