I am using a "dark" style keyboard for my standard TextField. This is for a login textfield, or "forget my password" textfield, where the user enters some info, submits it, and if it succeeds they are sent to another View, usually by a standard navigation controller popViewControllerAanimated:. An AlertView may appear in between.
The problem I've seen a lot is that the keyboard is open, a normal "dark" gray color, and then the user clicks Submit, an alert view may appear, and when dismissing that the the view shifts to the next screen with the previous keyboard going off screen. On the new screen another default style keyboard may or may not slide up and then disappear (without a textfield being focused on even!). Then, when clicking into another textfield, or going back to the previous view and clicking into a textfield, this black keyboard with white keys appears erroneously. It continues to appear for textfields until something is able to jar it back to the normal dark gray after a few clicks.
I've tried to dismiss the original keyboard before the popViewController happens, in various ways, but it doesn't seem to help. If the AlertView appears inbetween, I tied the popViewController to the delegate action on clicking the AlertView button. The keyboard usually doesn't disappear fast enough to leave before the push. A delay doesn't help it.
EDIT: The alertview seems to be a definite culprit here, interfering with the pop and keyboard somehow.
-(BOOL) textFieldShouldReturn:(UITextField *)textField{
[textfield resignFirstResponder];
[self.view endEditing:YES];
return YES;
}
-(IBAction)submitRequest {
[textfield resignFirstResponder];
[self.view endEditing:YES];
// make API call, if call succeeds run this block {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"..."
message:@"..."
delegate:delegate
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
dispatch_async(dispatch_get_main_queue(), ^{
[alert show];
});
// }
}
// delegate after alert OK is pressed
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
[self.navigationController popViewControllerAnimated:YES];
}
How can I avoid this black/white keyboard?