初始化部分:
[[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 中,此代码可以完美运行。