I had the same problem and here is my solution. Hope this helps.
- (void) keyboardWillShow: (NSNotification*) aNotification { [UIView animateWithDuration: [self keyboardAnimationDurationForNotification: aNotification] animations:^{ CGSize kbSize = [[[aNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
Add and remove event listeners.
- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyboardWillShow:) name: UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyboardDidShow:) name: UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyboardWillDisappear:) name: UIKeyboardWillHideNotification object:nil]; } - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver: self name: UIKeyboardWillShowNotification object: nil]; [[NSNotificationCenter defaultCenter] removeObserver: self name: UIKeyboardDidShowNotification object: nil]; [[NSNotificationCenter defaultCenter] removeObserver: self name: UIKeyboardWillHideNotification object: nil]; }
Metin that several events will be received during one keyboard animation.
Masterbeta
source share