Ios 在swift中隐藏和显示带有notificationCenter的键盘
我无法在我的SignUpViewController上显示和隐藏键盘Ios 在swift中隐藏和显示带有notificationCenter的键盘,ios,swift,Ios,Swift,我无法在我的SignUpViewController上显示和隐藏键盘 //Keyboard frame size var keyboard = CGRect() //Default function override func viewDidLoad() { super.viewDidLoad() //scrollView frame size self.scrollView.frame = CGRect(x: 0, y: 0, width: self.scrollV
//Keyboard frame size
var keyboard = CGRect()
//Default function
override func viewDidLoad() {
super.viewDidLoad()
//scrollView frame size
self.scrollView.frame = CGRect(x: 0, y: 0, width: self.scrollView.frame.size.width, height: self.scrollView.frame.size.height)
scrollView.contentSize.height = self.view.frame.height
scrollViewHeight = scrollView.frame.size.height
//check notificvations if keyboard is shown or not
let notificationCenter = NotificationCenter.default
NotificationCenter.default.addObserver(self, selector: #selector(SignUpVC.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(SignUpVC.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
}
例如,您必须设置一个uitextfield作为第一响应者。您试图实际显示键盘的内容是什么?在这里,您只是订阅事件,而不是显示或隐藏键盘。例如,如果您点击文本视图进行输入,并收到通知中心的通知,则会显示键盘。