tableViewCell在iOS11中编辑文本字段时不向上滚动

use*_*_aj 3 uitableview uitextfield ios swift3 ios11

当我点击表格视图中的文本字段时,单元格和键盘会出现,单元格会自动向上滚动以使文本字段可见.这在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 

        }         
    }     
}
Run Code Online (Sandbox Code Playgroud)

Adi*_*ava 6

更换 UIKeyboardFrameBeginUserInfoKey

UIKeyboardFrameEndUserInfoKey.

希望它有效.