xcode 如何确定用户是否按下/选择了 uitextfield?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5477349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to determine if user pressed/selected a uitextfield?
提问by user648244
Is there a way to determine if a user has selected a textfield and its active? I'm trying to implement some code this:
有没有办法确定用户是否选择了文本字段及其活动?我正在尝试实现一些代码:
if(textFieldsomething.isActive)
{
}
回答by Greg
You can check to see if the text field is editing:
您可以检查文本字段是否正在编辑:
if (textFieldSomething.isEditing) {
...
}
See the UITextField class referencefor details.
有关详细信息,请参阅UITextField 类参考。
回答by MBU
you can implement the textFieldDidBeginEditing function to catch the action event when the text field is being edited.
您可以实现 textFieldDidBeginEditing 函数来捕获正在编辑文本字段时的动作事件。
-(void)textFieldDidBeginEditing:(UITextField *)textField { //Keyboard becomes visible
//perform actions.
}