如何在向上滑动(显示)和向下滑动(隐藏)时删除UIKeyboard动画? -IOS9 Swift

时间:2016-01-27 03:47:04

标签: ios swift

我有一个视图,我需要始终显示键盘,但这并不容易,因为每当警报视图显示它关闭我的键盘时,我会在所述视图中以模态方式呈现另一个视图。

所以我的修复是使用假键盘作为imageview,它有键盘图像现在我可以随时显示我的键盘,但我想删除键盘的转换显示和隐藏在我的假键盘上。

我找到了this,但它没有在ios9上工作

1 个答案:

答案 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
}

以下是它的截图:

image