开发者社区> 问答> 正文

UIButton-编程创建问题

编程创建了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就成功了。

展开
收起
爵霸 2016-05-27 10:39:31 1901 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载