我在表格 View 单元格中添加了一个按钮。我的问题是,当我在调用方法 pressHonkBtn:(id)sender
时更改其标题时,它不会更改其标题。
如何解决这个问题。
最佳答案
像这样使用你的代码:
objective-C :
-(IBAction)pressHonkBtn:(id)sender
{
UIButton *tempBtn = (UIButton *)sender;
[tempBtn setTitle:@"YOUR_TITLE" forState:UIControlStateNormal];// YOUR_TITLE is your button title
[tempBtn setTitle:@"YOUR_TITLE" forState:UIControlStateHighlighted];
}
swift :
someUIButton.setTitle("String To Set", forState: UIControlState.Normal)
希望对你有帮助。
关于ios - 更改 UIButton 的标题不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16358670/