Type 'NSNotification.Name' has no member 'keyboardDidShowNotification'

前端 未结 4 1984
傲寒
傲寒 2020-12-05 13:42

I\'m getting this error with Swift 4.2

Type \'NSNotification.Name\' has no member \'keyboardDidShowNotification\'

Here is my cod

4条回答
  •  春和景丽
    2020-12-05 14:13

    I believe you use it like this now.

    NotificationCenter.default.addObserver(
        self, 
        selector: #selector(self.keyboardDidShow(notification:)), 
        name: UIResponder.keyboardDidShowNotification, object: nil) 
    
    /* You can substitute UIResponder with any of it's subclass */
    

    It is listed in UIResponder doc as a Type Property.

提交回复
热议问题