[英]Is UITextField empty?
To know if an UITextField is empty I used the following code: 要知道UITextField是否为空,我使用了以下代码:
if ( [ [textField text] isEqualToString:@""] )
But unfortunately it somehow fails to tell if the text field is empty. 但是不幸的是,它无法以某种方式判断文本字段是否为空。
What are the other ways? 还有哪些其他方式?
When [textField text] is empty, it equals to nil. 当[textField text]为空时,它等于nil。
Thank you. 谢谢。
也许尝试[[textField text] length] == 0
?
[textField hasText]
参见参考 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.