UITableView scroll up when keyboard appears in quick

I have a UITableView with 7 cells, and each cell has a text box inside. When the keyboard appears, it hides the last cell, so it’s pretty hard to see what was entered until the keyboard disappears.

Can someone tell me how I can scroll this UITableView until the keyboard appears, so I don't have this problem?

+6
source share
2 answers

Try the following:

 func textFieldDidBeginEditing(textField: UITextField) { tableView.setContentOffset(CGPointMake(0, textField.center.y-60), animated: true) } 
+5
source

Use a simple set of classes https://github.com/michaeltyson/TPKeyboardAvoiding

How to use:

For use with the UITableViewController classes, drop TPKeyboardAvoidingTableView.m and TPKeyboardAvoidingTableView.h into your project and make your UITableView TPKeyboardAvoidingTableView in xib. If you are not using xib with a controller, I don’t know an easy way to make it a UITableView special class: the path of least resistance is to create xib for it.

0
source

All Articles