Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在swift中隐藏和显示带有notificationCenter的键盘_Ios_Swift - Fatal编程技术网

Ios 在swift中隐藏和显示带有notificationCenter的键盘

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

我无法在我的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.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作为第一响应者。

您试图实际显示键盘的内容是什么?在这里,您只是订阅事件,而不是显示或隐藏键盘。例如,如果您点击文本视图进行输入,并收到通知中心的通知,则会显示键盘。