tableViewCell not scrolling up while editing a textfield in iOS11

533 views Asked by At

When i tap on a textfield in a table view cell and keyboard appears the cell automatically scrolls up to make the text field visible. This happens perfectly in ios 10 but not in iOS 11. Does anyone have a solution?

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 

        }         
    }     
}
1

There are 1 answers

1
Aditya Srivastava On BEST ANSWER

Replace UIKeyboardFrameBeginUserInfoKey

with

UIKeyboardFrameEndUserInfoKey.

Hope it works .