ios - 如何在 ios6 模拟器中显示虚拟键盘

标签 ios

如何在 ios6 Simulator(iphone 或 iPad)中显示虚拟键盘?我试过切换键盘选项,但什么都没有出现,你只能用代码让它出现吗?如果是这样,如何?

感谢您的任何建议。

最佳答案

没有“目标”就无法显示键盘。系统需要知道它应该将输入的文本发送到哪里。
因此,如果您有一个接受文本输入的 UIView 子类(例如 UITextField),则当用户点击该 View 时会显示键盘,或者您可以通过调用以编程方式触发它:

[textField becomeFirstResponder];
来自 iOS-Documentation Managing the Keyboard :

Displaying the Keyboard

When the user taps a view, the system automatically designates that view as the first responder. When this happens to a view that contains editable text, the view initiates an editing session for that text. At the beginning of that editing session, the view asks the system to display the keyboard, if it is not already visible. If the keyboard is already visible, the change in first responder causes text input from the keyboard to be redirected to the newly tapped view.

Because the keyboard is displayed automatically when a view becomes the first responder, you often do not need to do anything to display it. However, you can programmatically display the keyboard for an editable text view by calling that view’s becomeFirstResponder method. Calling this method makes the target view the first responder and begins the editing process just as if the user had tapped on the view.

If your application manages several text-based views on a single screen, it is a good idea to track which view is currently the first responder so that you can dismiss the keyboard later.

关于ios - 如何在 ios6 模拟器中显示虚拟键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13100558/

相关文章:

ios - adjustmentFontForContentSizeCategory 是否适用于自定义字体?

iOS:如果已安装,则使用自定义 URL 打开应用程序,否则使用 iTunes

IOS 自定义 Segue 和 ContainerView

ios - 检测 CA :TRUE in x509 Basic Contraints

ios - 通过自动布局添加分隔线

objective-c - 图片仅在ios6中以纵向模式显示

html - iOS Safari/Chrome 不会向上滚动以在 radio 输入上显示验证错误消息

ios - 实例成员 'image' 不能用于类型 'UIImageView'

ios - 快速组合 : `append` which does not require output to be equal?

ios - 为什么我不能在 UINavigationController 中更改后退按钮的字体?