I researched all over stackoverflow. I found too many solutions but they did not work properly. This is a typical ios question.
I have to move tableview when the keyboard appears. I tried following code:
func keyboardWillShow(notification: NSNotification) {
var info = notification.userInfo!
let keyboardFrame: CGRect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
let edgeInsets = UIEdgeInsetsMake(0, 0, keyboardFrame.size.height, 0)
self.tableView.contentInset = edgeInsets
self.tableView.scrollIndicatorInsets = edgeInsets
}
State 1: There is no keyboard and everything looks fine:
State 2: The keyboard appeared, and tableview is not showing the last row. You can compare with state 1.
How can I do this thing properly? If user scrolled to top then when touches the textfield, tableview should show same position, no last row. I mean I don't want any scroll to bottom code when keyboard appears. Tableview should remain same with/without keypoard appear status. You can check the Whatsapp I need exact same mechanism. How can I do this?
PS: Don't mind the textfield, I removed their move to above of keyboard code in order to test tableview.