When the home button gets pressed I want to hide the keyboard and restore my view to a sane state, so that when the app is started/foregrounded again, there is no textfield selected and the keyboard is hidden.
My app delegate has this implementation of the method:
- (void)applicationDidEnterBackground:(UIApplication *)application {
[tabBarController.view endEditing:YES];
}
The keyboard does indeed get removed, but what I don't get is this: Apple's docs say that a snapshot of the app is taken after the method returns. However this poses a problem with the keyboard slide-down animation. Sometimes when the app is started again for a short moment it shows the keyboard half-way down. I assume the screenshot is taken before the animation was finished.
What would I do to solve this, introduce a short timer in the applicationDidEnterBackground:
method? I wonder if there is a "cleaner" solution.
I've not tried this but what about turning animations off just before you resign the keyboard:
If this works you need to turn them back on in applicationWillEnterForeground