我有一个视图,我需要始终显示键盘,但这并不容易,因为每当警报视图显示它关闭我的键盘时,我会在所述视图中以模态方式呈现另一个视图。
所以我的修复是使用假键盘作为imageview,它有键盘图像现在我可以随时显示我的键盘,但我想删除键盘的转换显示和隐藏在我的假键盘上。
我找到了this,但它没有在ios9上工作
答案 0 :(得分:1)
如果我的键盘出现,这对我有用:
250
然后您可以像这样调用警报:
private func presentAlert(alertController: UIAlertController) {
dispatch_async(dispatch_get_main_queue(), {
guard let topViewController = UIApplication.sharedApplication().windows.last!.rootViewController else {
return
}
topViewController.presentViewController(alertController, animated:true,
completion:nil)
})
}
private func createAlert(title: String, message: String) -> UIAlertController {
let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
let cancelAction: UIAlertAction = UIAlertAction(title: "OK", style: .Cancel) {
action -> Void in
// Do something?
}
alertController.addAction(cancelAction)
return alertController
}
以下是它的截图: