2015-04-01 32 views
0

我的代碼:UIKeyboard通知處理程序觸發3次

-(void)viewWillAppear:(BOOL)animated { 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboard:) name:UIKeyboardWillChangeFrameNotification object:nil]; 
} 

-(void)viewWillDisappear:(BOOL)animated { 
    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
} 

-(void)handleKeyboard:(NSNotification*)notification { 
    NSLog(@"triggered"); 
} 

參見:

enter image description here

日漸消失的處理程序觸發一次爲正常,但是當3次出現。這是一個iOS錯誤?

+0

改爲使用'UIKeyboardWillShowNotification'名稱。有幫助。 – antonio 2015-04-01 09:14:28

+0

@antonio試過了,同樣的問題。 – Allen 2015-04-01 09:17:10

回答

0

可能對您的問題沒有幫助,但您需要致電[super viewWill…進行覆蓋。

-(void)viewWillAppear:(BOOL)animated

-(void)viewWillDisappear:(BOOL)animated

從文檔。

如果您重寫此方法,則必須在您的實現中調用超級在某個點上。

+0

沒有幫助,但無論如何,謝謝你的提示。 – Allen 2015-04-01 08:34:05

相關問題