【发布时间】:2012-10-10 20:50:37
【问题描述】:
我有一个 UIButton,上面写着“完成”。 我的 UIButton 驻留在我插入到 tableview 中的 UIView 中。 但是,当用户点击按钮时,我还想更新 UIButton 的标签以显示“不完整”。 按钮标签不更新! 如何设置按钮的标签? 谢谢!
【问题讨论】:
标签: objective-c ios ios5 ios6
我有一个 UIButton,上面写着“完成”。 我的 UIButton 驻留在我插入到 tableview 中的 UIView 中。 但是,当用户点击按钮时,我还想更新 UIButton 的标签以显示“不完整”。 按钮标签不更新! 如何设置按钮的标签? 谢谢!
【问题讨论】:
标签: objective-c ios ios5 ios6
当您希望更改按钮标题时,请使用以下命令:
UIButton *myButton;
//
//
//
[myButton setTitle:@"Incomplete" forState:UIControlStateNormal];
希望这会有所帮助。
【讨论】:
试试这样的:
if([[[button titleLabel] text] isEqualToString:@"complete"]){
[button setTitle:@"Incomplete" forState:UIControlStateNormal];
// do some stuff
}
【讨论】: