【发布时间】:2012-01-12 14:20:10
【问题描述】:
我想在UITableViewCell 中添加一个按钮。这是我的代码:`
if (indexPath.row==2) {
UIButton *scanQRCodeButton = [[UIButton alloc]init];
scanQRCodeButton.frame = CGRectMake(0.0f, 5.0f, 320.0f, 44.0f);
scanQRCodeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
scanQRCodeButton.backgroundColor = [UIColor redColor];
[scanQRCodeButton setTitle:@"Hello" forState:UIControlStateNormal];
[cell addSubview:scanQRCodeButton];
}`
现在,当我运行应用程序时,我只看到一个空白行!有什么想法吗?
【问题讨论】:
-
添加
[cell.contentView addSubview:scanQRCodeButton];后也可以松开按钮[scanQRCodeButton release];
标签: iphone objective-c uitableview uibutton