iOS9 dismissing keyboard causes crash

2019-05-21 07:55发布

问题:

When i try to run my app at iOS 9.1 simulator i have a crash

Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIInputWindowController: 0x7ff82b036e00>)

Crash happens in main function.

Crash happens when i try to dismiss the keyboard with

[self.username resignFirstResponder];

Also when you self.view.userInteractionEnabled = false;

I've read View appear with modal view animation instead of show (push) animation with similar issue - but i have only 1 root navigation controller

Any ideas?

iOS 9 only bug

回答1:

Issue was with UIViewController category

dealloc method was overridden to clean up notification callbacks.

And it caused a crash on iOS 9. Probably due to the fact [super dealloc] wasn't called (due to ARC restrictions)

Solution - remove dealloc method from category to the UIViewController subclasses