Swift 3 NSNotificationCenter Keyboardwillshow/hide

后端 未结 4 647
栀梦
栀梦 2020-12-06 17:27

I have a piece of code that worked in Swift 2 and I tried using Xcode to update the code to the newest version and I fixed everything except two issues.

I have this

4条回答
  •  误落风尘
    2020-12-06 17:53

    Check out the updated Swift Programming Language book. Pages 1027 and 1028 are what you're looking for. It should be something like this:

    func keyboardWillHide(_ notification: NSNotification) {…
    

    Notice the additional underscore above. Also:

    #selector(LoginViewController.keyboardWillHide(_:))
    

    You also might need to add @objc(keyboardWillHideWithNotification:) to your class.

提交回复
热议问题