我是新手objective-c.
谁能告诉我为什么在我运行代码时按钮没有出现。
这是我的代码:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
button1 = [[UIButton buttonWithType:UIButtonTypeRoundedRect]initWithFrame:CGRectMake(3, 3, 30, 30)];
[button1 setTitle:@"haha" forState:UIControlStateNormal];
[button1 setBackgroundColor: [UIColor blackColor]];
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:button1];
}