Apple IOS9 has been introduced for some time, originally thought should be very stable, but the fact is not so. Debugging a very good app on iOS 8 on an iOS 9.1 device one day has found a wonderful problem: You can't release the keyboard.
Trace debugging, discovering that the program crashes as long as the code is running to a resignfirstresponder (or endediting) method call. There is a God-general bad exec error.
Comment on this code, everything OK, but you can't put away the soft keyboard.
There are countless answers on the web, and only one answer is reliable:
Http://www.dahuatu.com/1LypEbbMmn.html
Next, let's demonstrate this bug, and you'll see that it's so easy to crash a normal app on iOS 8.
New project. Drag a TextField and button on the view controller. Create a Ibaction connection for the button:
-(Ibaction) FREEKB: (ID) Sender {
[Self.view Endediting:yes];
}
No other code should write anything. Run the program (on iOS 9.1 emulator or device), click TextField, Keyboard popup, click button, the keyboard is closed. Everything OK, no problem.
Now let's see how to kill it. Implement a category, whatever you call it (e.g. test):
@implementation Uiviewcontroller (Test)
-(void) dealloc{
}
@end
As you can see, only an empty Dealloc method is defined, and no code is written in the method.
Run the program (on iOS 9.1 emulator or device), click TextField, Keyboard popup, click button, the keyboard is closed. Program Crashes! Delete Dealloc method, run again, everything is OK.
Ok, demo finished, thank you!
IOS9 BUG: A bug that is very prone to crashes