开发者

iPad, UITextView, and firstResponder issues

I'm writing a universal iOS app that a text entry component to it. When the view with the UITextView in it is shown, I call [UITextView becomeFirstResponder] so the keyboard pops up. When the user taps done/save, the view controller calls pop on it's navigation controller, and the keyboard should disappear automatically.

This works fine on the iPhone/iPod touch, but on the iPad, the keyboard remains up, with the accessory view, even after the view is popped. I've tried everything: checking leaks with Instruments, static analyzer, explicitly calling [UITextView resignFirstResponder] multiple times, heap shots, and no matter what I can't get the keyboard to disappear once the view controller is popped or figure out why the heck it wouldn't be. This is a huge issue because the 'previous' view controller in the UINavigationController hierarchy doesn't have a text field, and the accessory view remains on top of the keyboard and when the buttons on it are tapped, they send messages to the deallocated view controller, causing a crash.

The only difference I can name between the iPhone/iPad version is that the iPhone version, of course, presents the navigation controller modally over the full screen, while on the iPad the navigat开发者_如何学编程ion controller is presented in UIModalPresentationFormSheet.

I hope this is enough information to allow someone to diagnose the issue. If it's not, I'll post a sample project.


If I recall correctly, the keyboard always shows up while something is presented in UIModalPresentationFormSheet. Try something different and see if that works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜