tableViewCell在iOS11中编辑文本字段时不向上滚动
问题描述:
当我点击表格视图中的文本字段时,单元格和键盘出现,单元格自动向上滚动以使文本字段可见。这在ios 10中完全发生,但在iOS 11中不会发生。有没有人有解决方案?tableViewCell在iOS11中编辑文本字段时不向上滚动
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
。
希望它有效。
+0
这对iOS10和iOS11都适用。 Thnx 我也有这个链接。https://forums.developer.apple.com/thread/81407 –
提供您的代码 – Govaadiyo
FUNC displayKeyboard(_通知:通知) { 如果让USERINFO = notification.userInfo { 如果让keyboardSize =(USERINFO [UIKeyboardFrameBeginUserInfoKey如NSValue)?. cgRectValue { myTableView.contentInset = UIEdgeInsetsMake(0,0,keyboardSize.height,0) myTableView.scrollIndicatorInsets = myTableView.contentInset }} } 是 –
这possble附加项目 –