I believe I've come across a bug in iOS 7. When a UITextView is contained in a modal view, having its inputview property changed from a custom view to nil (in order to bring back the system keyboard) will cause the app to crash after the modal view is dismissed.
This crash only occurs under iOS 7. Previous versions of iOS did not exhibit this problem.
I wrote a small sample app to demonstrate the problem. Compile the launch the app and do the following:
As soon as the ViewController is dismissed, the app crashes immediately. The crash log sometimes, but not always, refers to an unrecognized selector being sent to an object. The object's type is different every time the crash is reproduced.
Has anyone else come across this sort of bug?
I'm sorry, I'm not exactly understand you. Here is a solution that does not lead to the crash.
UIView* emptyView;
-(IBAction)setToEmpty:(id)sender {
[self.textView resignFirstResponder];
if (emptyView == nil)
emptyView = [[UIView alloc] initWithFrame:CGRectZero];
self.textView.inputView = emptyView;
[self.textView becomeFirstResponder];
// emptyView = nil; // If you comment out the this line, the app will crash
}
If you enable zombie objects, you can see the following error:
CrashTest[16706:a0b] * -[UIView _overrideInputViewNextResponderWithResponder:]: message sent to deallocated instance 0x8e88680
ARC in ios7 works in a different way. Apparently you can not release the object, which was firstResponder, before closing mainView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With