【问题标题】:IQKeyboardManager hides keyboard when tapped on UITextFieldIQKeyboardManager 在 UITextField 上点击时隐藏键盘
【发布时间】:2015-09-10 07:03:04
【问题描述】:

我有两个文本字段。我在textFieldDidBeginEditing 中使用此代码,但它不会关闭键盘。

-(void)textFieldDidBeginEditing:(UITextField *)textField {
    if(textField==textFieldOne)
    {

    }

    else if (textField==textFieldTwo)
    {
        [[IQKeyboardManager sharedManager]resignFirstResponder]
    }
}

【问题讨论】:

  • 你找到解决方案了吗?

标签: ios iphone uitextfield resignfirstresponder iqkeyboardmanager


【解决方案1】:

这可能有助于尝试

-(void)textFieldDidBeginEditing:(UITextField *)textField {
if(textField==textFieldOne)
{

}

else if (textField==textFieldTwo)
{
[self.view endEditing:YES];
}
}

【讨论】:

  • shouldResignOnTouchOutside 使用 IQKeyboardManager 的这个属性来隐藏键盘
  • 只有当我们在外面点击时才会隐藏键盘,在第二个文本字段内点击时才会隐藏。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-30
  • 1970-01-01
  • 1970-01-01
  • 2011-05-03
  • 2022-01-23
相关资源
最近更新 更多