The black ios keyboard with white text appears after changing the view when you open the keyboard

I use a "dark" style keyboard for my standard TextField. This is for the text input field or the โ€œforget my passwordโ€ text field, when the user enters some information, passes it on, and if it is successful, they are sent to a different view, usually using the standard navigation controller popViewControllerAanimated :. AlertView may appear between them.

The problem that I saw a lot is that the keyboard is open, the normal โ€œdarkโ€ gray color, and then the user presses the โ€œSendโ€ button, a warning may appear, as well as when evading the next screen with the previous keyboard coming out of screen. On a new screen, another default style keyboard may or may not move up and then disappear (without an even-focused text box!). Then, when you click in another text field or return to the previous view and click on the text field, this black keyboard with white keys erroneously appears. It still appears for text fields until something can return it to normal dark gray in a few clicks.

I tried to reject the original keyboard before popViewController happens differently, but it doesn't seem to help. If an AlertView appears between them, I bound the popViewController to the delegate action when I clicked the AlertView button. Typically, the keyboard does not disappear fast enough to exit before being pressed. Delay does not help.

EDIT: The warning seems to be the definite culprit here, somehow interfering with the pop and keyboard.

-(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 to avoid this black and white keyboard?

enter image description here

+5
source share
1 answer
 Try using the below code. It works fine for iOS 8 and below version if (IS_OS_8_OR_LATER) { UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:B_title style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { [self.navigationController popViewControllerAnimated:YES]; }]; [alertVC addAction:cancelAction]; [self presentViewController:alertVC animated:YES completion:nil]; } else{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [alert show]; } } 
+3
source

Source: https://habr.com/ru/post/1245804/


All Articles