2013-02-02 15 views
7

Sto rilevando la proiezione/nascondere la tastiera aggiungendo questo codice nel viewDidLoad:Rimuovere NSNotificationCenter osservatore

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(keyboardDidHide:) 
              name:UIKeyboardDidHideNotification 
              object:nil]; 

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(keyboardWillShow:) 
              name:UIKeyboardWillShowNotification 
              object:nil]; 

Ad un certo punto però voglio rimuovere questi osservatori, senza chiamare

[[NSNotificationCenter defaultCenter] removeObserver:self]; 

perché questo rimuove tutti gli osservatori e ho altri osservatori che non voglio rimuovere. Come posso rimuovere solo quei due ??

risposta

28
[[NSNotificationCenter defaultCenter] removeObserver:self 
               name:UIKeyboardDidHideNotification 
               object:nil]; 

[[NSNotificationCenter defaultCenter] removeObserver:self 
               name:UIKeyboardWillShowNotification 
               object:nil]; 
1

Utilizzare [[NsNotificationCenter defaultCenter] removeObserver:self name: UIKeyboardWillShowNotification object:nil]

Problemi correlati