Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios black keyboard with white text appears after view change when keyboard open

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?

enter image description here

like image 383
Miro Avatar asked Mar 26 '16 01:03

Miro


People also ask

Why did my keyboard change color from black to white?

Your virtual keyboard (On-Screen or Touch keyboard) may have changed its color from black to white as a result of a change of the apps’ color mode. Moreover, conflicting keyboard applications (for example, Touch keyboard hindering the operation of On-Screen Keyboard) may also cause the issue at hand.

How do I get black text on the background of iPad?

You can change your iPad's background to have a a lighter coloured wallpaper image via Settings > Wallpaper, that should give you black text on it - a wallpaper that is close to however the light/dark threshold is determined may (I assume, I haven't seen it mentioned) occasionally give different white or black text

Why is my keyboard not showing uppercase on my iPad?

If you have difficulty seeing the onscreen keyboard, you can set it to display only uppercase letters. Go to Settings > Accessibility > Keyboards, then turn off Show Lowercase Keys. Rotate iPad to landscape orientation to use a larger keyboard for typing in many apps, including Mail, Safari, Messages, Notes, and Contacts.

How do I make my keyboard easier to use on iPad?

1 Go to Settings > Accessibility > Keyboards. 2 Do any of the following: - Show only uppercase keys on the iPad keyboard.- Adjust the key repeat rate on hardware keyboards.- Use Sticky Keys to press and hold modifier keys, such as Command and Option, as you press another key.- Use Slow Keys to adjust the time between when a key is ... See More...


1 Answers

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];
        }
}
like image 75
jbchitaliya Avatar answered Sep 30 '22 17:09

jbchitaliya