【发布时间】:2018-02-03 03:21:41
【问题描述】:
当我点击表格视图单元格中的文本字段并出现键盘时,单元格会自动向上滚动以使文本字段可见。这在 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
}
}
}
【问题讨论】:
-
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)给我键盘的高度为0。
标签: ios uitableview swift3 uitextfield ios11