Error with notification names while converting code to Swift 4.2

后端 未结 3 631
没有蜡笔的小新
没有蜡笔的小新 2020-12-20 16:07

The code below was working fine before Swift 4.2:

NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChange(notification:)), name:          


        
3条回答
  •  礼貌的吻别
    2020-12-20 16:54

    The selected answer is incomplete and produce compilers error,

    Cannot invoke 'addObserver' with an argument list of type '(RegistrationViewController, selector: Selector, name: NSNotification.Name)'

    Here is the working format,

    NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChange(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
    

提交回复
热议问题