我为文本字段和文本视图使用了以下代码。它对于文本字段工作正常,但是键盘仍然隐藏着文本视图。
@objc func keyboardWillShow(notification: NSNotification) {
guard let info = notification.userInfo, let keyboardFrameValue = info[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue else { return }
let keyboardFrame = keyboardFrameValue.cgRectValue
let keyboardSize = keyboardFrame.size
let contentInsets = UIEdgeInsets(top: 0.0, left: 0.0, bottom: keyboardSize.height + 100, right: 0.0)
tableView.contentInset = contentInsets
tableView.scrollIndicatorInsets = contentInsets
}
@objc func keyboardWillHide(notification: NSNotification) {
let contentInsets : UIEdgeInsets = UIEdgeInsets.init(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
self.tableView.contentInset = contentInsets
self.tableView.scrollIndicatorInsets = contentInsets
self.view.endEditing(true)
}任何帮助都将不胜感激。
发布于 2020-01-30 15:54:50
https://stackoverflow.com/questions/59907779
复制相似问题