In my application I am adding following observer in init method of class A.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
然後我從擴展類A keyboardWillShow和keyboardWillHide方法B類都寫在超類,即A類。但是應用程序會引發以下異常,當我點擊一些的TextView輸入文字。iOS版 - keyboardWillShow:無法識別的選擇發送到實例
terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[B keyboardWillShow:]: unrecognized selector sent to instance xyz'
這是混淆因爲方法已經寫在晚飯B類的。如果是由於無效的參數,它再怎麼可以作爲參數通過的iOS本身傳遞。
你怎麼定義keyboardWillToggle?是否需要爭論? – foggzilla
請發佈您的keyboardWillToggle方法聲明: – Marco
您的錯誤說「keyboardWillShow」,但您的代碼有「keyboardWillToggle」。這是你的問題中的錯字,還是你的代碼中有什麼? – rdelmar