Another take on the “keyboard obscures UITextField” problem

后端 未结 3 2024
不思量自难忘°
不思量自难忘° 2021-01-13 13:56

I know that this is a common problem and the UITableViewController fixed this is iPhone SDK 3.0, but the UITableViewController is not working as I expect, probably due to ho

3条回答
  •  庸人自扰
    2021-01-13 14:38

    (Repeating my answer from another SO question):

    I personally highly recommend using TPKeyboardAvoiding by Michael Tyson.

    It's very easy to use... (quoting from the Read Me):

    For use with UITableViewController classes, drop TPKeyboardAvoidingTableView.m and TPKeyboardAvoidingTableView.h into your project, and make your UITableView a TPKeyboardAvoidingTableView in the xib. If you're not using a xib with your controller, I know of no easy way to make its UITableView a custom class: The path of least resistance is to create a xib for it.

    For non-UITableViewControllers, drop the TPKeyboardAvoidingScrollView.m and TPKeyboardAvoidingScrollView.h source files into your project, pop a UIScrollView into your view controller's xib, set the scroll view's class to TPKeyboardAvoidingScrollView, and put all your controls within that scroll view. You can also create it programmatically, without using a xib - just use the TPKeyboardAvoidingScrollView as your top-level view.

提交回复
热议问题