大佬教程收集整理的这篇文章主要介绍了Swift 3 NSNotificationCenter键盘将显示/隐藏,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
查阅更新的《Swift编程语言》书。您正在寻找1027和1028页。应该是这样的:
func keyboarDWillHIDe(_ notification: Nsnotification) {…
请注意上面的其他下划线。也:
#SELEctor(LoginVIEwController.keyboarDWillHIDe(_:))
您可能还需要添加@objc(keyboarDWillHIDeWithNotification:)
到课程中。
我有一段可以在Swift 2中使用的代码,我尝试使用Xcode将代码更新为最新版本,并修复了除两个问题以外的所有内容。
我有这个代码:
let loginvc: LoginVC = self.storyboard?.instantiateViewController(withIdentifier: "LoginVC") as! LoginVC
NotificationCenter.defaultCenter().addObserver(self,SELEctor: #SELEctor(LoginViewController.keyboardWillShow(_:)),name: UIKeyboardWillShowNotification,object: nil)
NotificationCenter.defaultCenter().addObserver(self,SELEctor: #SELEctor(LoginViewController.keyboardWillHide(_:)),name: UIKeyboardWillHideNotification,object: nil)
与此配对:
func keyboardWillShow(notification: Nsnotification) {
consTraint.constant = -100
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}
func keyboardWillHide(notification: Nsnotification) {
consTraint.constant = 25
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}
在第一部分,我现在得到一个错误提示
我不明白为什么它没有看到下面的方法。
有人知道这个问题的解决方案吗?
以上是大佬教程为你收集整理的Swift 3 NSNotificationCenter键盘将显示/隐藏全部内容,希望文章能够帮你解决Swift 3 NSNotificationCenter键盘将显示/隐藏所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。