Uitableview 键盘正在隐藏UITextView
我正在为文本字段和文本视图使用以下代码。对于文本字段,它工作正常,但键盘仍隐藏textviewUitableview 键盘正在隐藏UITextView,uitableview,uitextview,swift4.2,Uitableview,Uitextview,Swift4.2,我正在为文本字段和文本视图使用以下代码。对于文本字段,它工作正常,但键盘仍隐藏textview @objc func keyboardWillShow(notification: NSNotification) { guard let info = notification.userInfo, let keyboardFrameValue = info[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue else {
@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)
}
任何帮助都将不胜感激。请使用下面提供的库链接
非常感谢。但我使用了tableView.scrollToRow和textview委托,它起了作用。