初始化区段:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification object:nil];
一些方法:
- (void) keyboardWillShow:(NSNotification*) aNotification {
// TO DO
}
释放内存区域:
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
所以在iOS 6.1中,在展示视图后不会调用keyboardWillShow函数......而在iOS 6.0中,此代码完美运行。