Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView Keyboard with keyboardAccessoryView turns blue (is inverted) after Springboard

On a iOS8 device or iOS8 simulator:

I have a UITextView which becomes first responder. Everything is fine until the app resigns active (via home key press).

Upon the app becoming active once more the keyboard's appearance is mutated - see image

enter image description here

The keyboard does have an keyboardAccessoryView which I have removed from the image for client privacy. However if remove the keyboardAccessoryView the bad behaviour does not occur.

The only solution I have to date is to resignFirstResponder on UIApplicationWillResignActiveNotification and becomeFirstResponder on UIApplicationDidBecomeActiveNotification.

Has anyone else seen this issue and [hopefully] fixed it?

For completeness here is a screenshot of the keyboard before the app goes to Springboard

enter image description here

like image 246
Damo Avatar asked Nov 10 '22 01:11

Damo


1 Answers

The best mitigation so far is as follows -

Add notification handlers to capture when the app becomes active / reactive

[[NSNotificationCenter defaultCenter]addObserver:self
                                        selector:@selector(activateKeyboard)
                                            name:UIApplicationDidBecomeActiveNotification
                                          object:nil];

[[NSNotificationCenter defaultCenter]addObserver:self
                                        selector:@selector(deactivateKeyboard)
                                            name:UIApplicationWillResignActiveNotification
                                          object:nil];

Then after finding this SO answer which is a bit old I tried to make the becomeFirstResponder happen as quickly as possible.

- (void)activateKeyboard;
{
  [UIView animateWithDuration:0.0f
               animations:^{
                 [self.textView becomeFirstResponder];
               }];
}

- (void)deactivateKeyboard;
{
  [self.textView resignFirstResponder];
}
like image 76
Damo Avatar answered Nov 14 '22 23:11

Damo