我试图在键盘出现时尝试实现UIKeyboardWillShowNotification
来处理我的观看位置。
我加上我的观察者:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow", name: UIKeyboardWillShowNotification, object: nil)
然后我有keyboardWillShow
功能:
func keyboardWillShow(notification: NSNotification){
//Need to access to the notification here
}
在函数keyboardWillShow
中,我需要收到NSNotification
才能访问用户信息,但我收到此错误:
"无法识别的选择器发送到实例0x7fd993e7d020"
答案 0 :(得分:7)
你忘了冒号:
。将其更改为:
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)