Are there any changes to the behavior of UIKeyboardWillShowNotification in iOS 8?

I had a simple block animation UIView

that handles animating a group of text boxes in a view when the keyboard shows (and animates them when the keyboard is hidden). This works fine in iOS 6 and 7, but now I am getting the wrong behavior and it all points to some change in UIKeyboardWillShowNotification

.

I set up a sandboxed project to test this further in a single text box, with two buttons that call exactly the same methods that are triggered for keyboard notifications WillShow

and WillHide

. See the results in this video:

Sample video

This seems to be a bug to me, or it might be a change in the behavior of this notification. Does anyone know if this is intended and / or what can be done about it?

Here's the relevant code:

- (void)viewWillAppear:(BOOL)animated
{
     [super viewWillAppear:animated];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}

- (void)viewWillDisappear:(BOOL)animated
{
     [super viewWillDisappear:animated];
     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}

- (void)keyboardWillShow:(NSNotification *)notification
{
     [UIView animateWithDuration:0.3 animations:^{
          self.textField.frame = CGRectOffset(self.textField.frame, 0.f, _destY - _origY);
     }];
}

- (void)keyboardWillHide:(NSNotification *)notification
{
     [UIView animateWithDuration:0.3 animations:^{
          self.textField.frame = CGRectOffset(self.textField.frame, 0.f, _origY - _destY);
     }];
}

      

+2


source to share





All Articles