在 iOS11 中编辑文本字段时 uitableViewCell 不向上滚动
tableViewCell not scrolling up while editing a textfield in iOS11
当我点击 table 视图单元格中的文本字段并且出现键盘时,单元格会自动向上滚动以使文本字段可见。这在 ios 10 中完美发生,但在 iOS 11 中没有。有人有解决方案吗?
func displayKeyboard(_ notification: Notification) {
if let userInfo = notification.userInfo {
if let keyboardSize = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
myTableView.contentInset = UIEdgeInsetsMake(0, 0, keyboardSize.height, 0) myTableView.scrollIndicatorInsets = myTableView.contentInset
}
}
}
替换UIKeyboardFrameBeginUserInfoKey
和
UIKeyboardFrameEndUserInfoKey
.
希望有用。
当我点击 table 视图单元格中的文本字段并且出现键盘时,单元格会自动向上滚动以使文本字段可见。这在 ios 10 中完美发生,但在 iOS 11 中没有。有人有解决方案吗?
func displayKeyboard(_ notification: Notification) {
if let userInfo = notification.userInfo {
if let keyboardSize = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
myTableView.contentInset = UIEdgeInsetsMake(0, 0, keyboardSize.height, 0) myTableView.scrollIndicatorInsets = myTableView.contentInset
}
}
}
替换UIKeyboardFrameBeginUserInfoKey
和
UIKeyboardFrameEndUserInfoKey
.
希望有用。