没有实现methodSignatureForSelector错误:键盘通知

时间:2016-10-27 08:46:23

标签: ios swift

我正在尝试使用单独的类来处理键盘通知。

类KeyboardHandling:

class KeyboardHandling{


class func addObserverKeyboardWillShow(){

    NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: .UIKeyboardWillShow, object: nil)

}

@objc func keyboardWillShow(notification: NSNotification){

    let duration = notification.userInfo![UIKeyboardAnimationDurationUserInfoKey] as! Double

    print(duration)
  }
}

MainVC:

class MainVC: UIViewController {

//MARK: Outlets
@IBOutlet weak var textInput: UITextField!
@IBOutlet weak var bottomToolbar: UIToolbar!
@IBOutlet weak var toolbarBottonConstraint: NSLayoutConstraint!

//MARK: Variables
var toolBarIntialBottomConstraint: CGFloat!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func viewDidAppear(_ animated: Bool) {

    toolBarIntialBottomConstraint = toolbarBottonConstraint.constant
    KeyboardHandling.addObserverKeyboardWillShow()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
   }
}

addObserverKeyboardWillShow() 类函数时,该实现非常有效。

否则我收到错误

错误截图(Xcode 8.0): Console O/P

有人可以解释为什么一样吗?

0 个答案:

没有答案