Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll UITableView up when keyboard appears in swift [duplicate]

I have a UITableView with 7 cells and every cell has a text field inside it. When the keyboard appears it hides the last cell so it is quite difficult to see what has been input until and unless the keyboard disappears.

Can anyone guide me how I can scroll this UITableview up when the keyboard appears so I don't have this problem?

like image 940
neena Avatar asked Dec 16 '15 15:12

neena


1 Answers

Try this one:

func textFieldDidBeginEditing(textField: UITextField) {
    tableView.setContentOffset(CGPointMake(0, textField.center.y-60), animated: true)
}
like image 177
Ayush Yadav Avatar answered Oct 05 '22 23:10

Ayush Yadav