键盘隐藏显示的额外空间问题

希望你一切顺利!

我在一个项目中有一个使用过的IQKeyboardManager库,我有一个屏幕,其中我遇到了一个额外空间问题,请参阅图片。

问题链接( http://sofzh.miximages.com/ios/Screen Shot 2018-02-05 at 5.47.54 PM.png?dl=0 )

我不想改变实现,但如果你使用它,你将看不到任何空格

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillShow(_:)), name:NSNotification.Name.UIKeyboardWillShow, object: self.view.window) NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillHide(_:)), name:NSNotification.Name.UIKeyboardWillHide, object: self.view.window) 

//

  @objc func handleKeyboardDidShow (notification: NSNotification) { let keyboardRectAsObject = notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue var keyboardRect = CGRect.zero keyboardRectAsObject.getValue(&keyboardRect) self.containerViewBotcon.constant = -1 * keyboardRect.height UIView.animate(withDuration: 0.5,animations: { self.view.layoutIfNeeded() }) } @objc func handleKeyboardWillHide(notification: NSNotification) { self.containerViewBotcon.constant = 0 UIView.animate(withDuration: 0.5,animations: { self.view.layoutIfNeeded() }) }