iOS 8 Swift:当模态显示UIAlercontroller时,如何保持键盘显示? [英] iOS 8 Swift : How to keep the keyboard displayed when the UIAlercontroller is presented modally?

查看:68
本文介绍了iOS 8 Swift:当模态显示UIAlercontroller时,如何保持键盘显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文非常简单,有一个带有文本字段的UIViewcontroller可以输入电话号码.文本框处于使用键盘的编辑模式.

The context is pretty simple, there is a UIViewcontroller with a textfield to enter a phone number. The textfield is in editing mode with keyboard.

输入数字后,用户可以点击显示警报控制器的按钮.由于警报是以模态显示的,因此它覆盖了UIViewcontroller并移除了键盘,因此不再启用编辑功能.

When the number is entered, the user can tap a button which displays an alert controller. As the alert is presented modally it covers the UIViewcontroller and removes keyboard, the editing is no more enabled.

因此,我的问题是,如何使键盘显示在警报后面?

Thus my question, what should be done to keep the keyboard displayed behind the alert?

推荐答案

此解决方案有效

let rootViewController: UIViewController = UIApplication.sharedApplication().windows[1].rootViewController!!
rootViewController.presentViewController(alert, animated: true, completion: nil)

这篇关于iOS 8 Swift:当模态显示UIAlercontroller时,如何保持键盘显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆