带标签属性的UIButton

时间:2011-07-25 16:56:31

标签: iphone objective-c uibutton

我使用。

获取带有标签托架名称的UIButton
UIButton *mybutton=[[UIButton alloc]init];

mybutton=(UIButton*)[cell viewWithTag:5];

和     UIButton * mybutton =(UIButton *)[cell viewWithTag:5];

这很好。但是当我使用

更改文本(带标签按钮)时
[mybutton setTitle:@"hello" forState:UIControlStateNormal];

App因此错误而崩溃

[UITableViewCell setTitle:forState:]: unrecognized selector sent to instance 0x4b6f540'

* 首次调用堆栈:

任何解决方案??

提前致谢

1 个答案:

答案 0 :(得分:2)

与您的contentView一起使用

    mybutton=(UIButton*)[cell.contentView viewWithTag:5];