Q:

Setting UIImage as background of a UIButton

Whats wrong with the following piece of code:
    UIButton *button = [[UIButton alloc]init];
    CGRect frame = CGRectMake(180, 10, 33, 33);
    button.frame = frame;
    button.tag = 1001;
    UIImage *image = [[[UIImage alloc]init]autorelease];
    image = [UIImage imageNamed:@"icon.png"];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [image release];
    [button release];

If this is wrong where does it need correction and why?

A:

I see several problems:

You sent autorelease to image, then manually released it.
You released button, but you didn't add it as a subview to anything. So basically, you did all that for nothing.
You instantiate UIImage, then you do instantiate it again. in the next line: Instead just do:
UIImage *image = [UIImage imageNamed:@"icon.png"];
and delete UIImage *image = [[[UIImage alloc]init]autorelease]; and [image release]; statement. 

A:

You can try this
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(180, 10, 33, 33);;
button.tag = 1001;
UIImage *image = [UIImage imageNamed:@"icon.png"];
if (image == nil) {
    NSLog(@"can't find icon.png");
} else {
    [button setBackgroundImage:image forState:UIControlStateNormal];
}
//add button to the parent's view

