编程创建了UIButton:
- (void)viewDidLoad
{
[paymentsHomeView setFrame:CGRectMake(0, 0, 320, 520)]; // paymentsHomeView is added and referenced in IB
UIButton *paymentButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 45, 300, 41)];
paymentButton.titleLabel.text = @"Button";
paymentButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[paymentButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.paymentsHomeView addSubview:paymentButton];
[super viewDidLoad];
}
-(void) buttonClicked {
NSLog(@"buttonClicked");
}
什么也没输出,Button没创建成功。
但是同样方法创建UITextField就成功了。
谢谢,请指点