在iOS中,键盘的速度非常慢

在iOS中,键盘的速度非常慢,ios,swift,keyboard,Ios,Swift,Keyboard,我有一个带有文本字段的应用程序。如果TextField为空,则只需一个按钮即可显示UIAlertView。当用户点击UIAlertView中的按钮时,他必须返回文本字段 我正在为此使用self.TextField.becomeFirstResponder()。它起作用了。但问题是键盘的显示速度非常慢。看起来在显示之前有一秒的延迟 if TextField.text?.isEmpty ?? true { let alert = UIAlertController(title:

我有一个带有文本字段的应用程序。如果TextField为空,则只需一个按钮即可显示
UIAlertView
。当用户点击
UIAlertView
中的按钮时,他必须返回文本字段

我正在为此使用
self.TextField.becomeFirstResponder()
。它起作用了。但问题是键盘的显示速度非常慢。看起来在显示之前有一秒的延迟

     if TextField.text?.isEmpty ?? true {

     let alert = UIAlertController(title: "Title", message: "Text", preferredStyle: .alert)
     alert.addAction(UIAlertAction(title: "Okay", style: .cancel, handler: { (action: UIAlertAction!) in

     self.TextField.becomeFirstResponder()
     }))

     self.present(alert, animated: true)
     print("textField is empty")

     } else { ...

确保在
Debug
菜单中禁用
慢速动画


展示一些您如何调用的代码
成为第一响应者
。还要注意,有时稍微延迟是正常的。当您的
UIAlertController
挡道时,键盘无法显示。谢谢您的回答。代码部分被添加到帖子中。我有一秒的延迟,即使我将self.present设置为false。