I’m attempting to create a view with two UIButtons. The code compiles without any error but the buttons don’t have any labels and they can’t be clicked.

-(id)initWithTabBar {
if ([self init]) {
self.title = @"Tab1";
self.tabBarItem.image = [UIImage imageNamed:@"promoters.png"];
self.navigationItem.title = @"Nav 1";
}
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Button" forState:UIControlStateNormal];
[button addTarget:self action:@selector(facebookAuthorize) forControlEvents:UIControlEventTouchDown];
[button setFrame:CGRectMake(10, 10, 100, 100)];
[self.view addSubview:button];
[button release];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button2 setTitle:@"Button" forState:UIControlStateNormal];
[button2 addTarget:self action:@selector(facebookLogin) forControlEvents:UIControlEventTouchDown];
[button2 setFrame:CGRectMake(110, 10, 100, 100)];
[self.view addSubview:button2];
[button2 release];
return self;
}
Don’t release those buttons. They are created as autoreleased objects. As described in documentation:
None of these words appear in buttonWithType:, so you don’t take responsibility and you are safe to assume it’s autoreleased.