4
我檢測到鍵盤將顯示下面的代碼。但是,當我使用pushViewController推到另一個屏幕並在該屏幕中打開鍵盤時,keyboardWillShow會被調用!這真的是對的嗎?UIKeyboardWillShowNotification從堆棧中的下一個班級錯誤調用
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
// register for keyboard notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
雖然+1您可能想提及如何刪除該通知的觀察者。 –
是的Praveen。我只是試圖找出在哪裏把下面的代碼 - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; –
類似 - (void)viewDidUnload { [super viewDidUnload]; \t [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; //取消註冊鍵盤通知,但不可見。 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; } –