aj_ios
aj_ios

Reputation: 155

tableViewCell not scrolling up while editing a textfield in iOS11

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 

        }         
    }     
}

Upvotes: 3

Views: 533

Answers (1)

Aditya Srivastava
Aditya Srivastava

Reputation: 2650

Replace UIKeyboardFrameBeginUserInfoKey

with

UIKeyboardFrameEndUserInfoKey.

Hope it works .

Upvotes: 6

Related Questions