问题
Since updating to iOS 6 I have this weirdest bug when trying to make an UITextField or UITextView firstResponder.
...it doesn't work.
I am not able to select the field or view and bring up the keyboard, nor is there a cursor or anything. The weirdest thing is that it is only not working for SOME fields, other ones in different viewcontrollers work without trouble.
I have:
[self.window makeKeyAndVisible];
self.window.rootViewController = self.viewController;
in my appDelegate. It worked and still works without problems with iOS 5.
Any ideas on what it could be?
Thanks!
回答1:
I found out what was causing the problem. From the viewcontroller I present the new viewcontroller from a textfield was firstResponder. So when I cancel this by calling
[textview resignFirstResponder];
or
[self.view endEditing:YES];
BEFORE presenting the new viewcontroller, it works without problems. Question remains.... Why is this? And is there a better way to overcome this? I don't feel much for resigning every textfield throughout my app...
回答2:
I know this post is old, but if it help, in iOS6 yo also need to resign the responder in the "granparents" views.
Ex:
Search View (don't resign responder) -> Detail View -> Super Detail View (This one have the problem).
Detail View dont have first reponder, but Search View has it.
We have to resign the responder in Search view to solve the problem in Super Detail View.
I assume that we also have to resign responder in the previws controllers of Search View.
来源:https://stackoverflow.com/questions/12585463/some-uitextfields-dont-respond-in-ios6