iOS 4.2 的键盘问题
我的应用程序在运行 iOS 4.1 的 iPhone 上正常运行,但在 iOS 4.2 上却不行。我将 UIInputField 设置为第一响应者,但键盘不显示。在viewDidLoad方法中调用becomeFirstResponder。这是一个错误还是苹果做出了重大改变?我正在使用 Xcode 3.2.5。
My app works as supposed on an iPhone running iOS 4.1 but not on iOS 4.2. I have an UIInputField set to first responder but the keyboard does not show up. The becomeFirstResponder is called in the viewDidLoad method. Is it a bug or has Apple made drastic changes? I'm using Xcode 3.2.5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
输入字段是否启用了用户交互? iOS 4.2 中现在要求这样做。
Does the input field have User Interaction Enabled? This is now required in iOS 4.2.
-viewDidLoad
在视图首次初始化时调用,而不一定在显示时调用。尝试在-viewDidAppear:
内调用-becomeFirstResponder
:-viewDidLoad
is called when your view is first initialized, not necessarily when it's displayed. Try calling-becomeFirstResponder
inside-viewDidAppear:
instead:在 Apple 开发者论坛 (https://devforums.apple.com/message/325348#325348) 上找到了一个线程,其中描述了解决方案。在调用 beginResponder 之前,最好在 viewDidLoad 方法中将 UITextField 属性 userInteractionEnabled 设置为 YES。
Found a thread at the Apple Developer Forums (https://devforums.apple.com/message/325348#325348) where a solution was described. Set the UITextField property userInteractionEnabled to YES before a call to becomeFirstResponder is made, preferably in the viewDidLoad method.