需要检查IBOutLet UIButton *button
是否没有写入文字。
要编码什么?
NSLog(@"%@", [button titleForState:UIControlStateNormal]); //it gives (null)
我应该写决定声明吗?
答案 0 :(得分:1)
确保您已设置UIControlState
的标题,如下所示:
[button setTitle:@"Click Me!" forState:UIControlStateNormal];
否则,一切都应该正常工作。
<强>更新强>
要检查它是否没有文字,请使用:
if (![menuItemButton titleForState:UIControlStateNormal]) {
NSLog(@"YES, no text.");
} else {
NSLog(@"no, there is text.");
}
答案 1 :(得分:0)
最好检查button.labelTitle.text
的长度。
感谢你们的答案。