After a while research on the internet, I've found that Michael Tyson has built a drop-in solution for such kind of problems. He packs everything that one needs into a class and puts the sources on GitHub.
If you follow the instruction on the Github, the task with UITextField and Keyboard is easy as a cake!
Usage
For use withUITableViewController
classes, dropTPKeyboardAvoidingTableView.m
andTPKeyboardAvoidingTableView.h
into your project, and make your UITableView aTPKeyboardAvoidingTableView
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 theTPKeyboardAvoidingScrollView.m
andTPKeyboardAvoidingScrollView.h
source files into your project, pop aUIScrollView
into your view controller's xib, set the scroll view's class toTPKeyboardAvoidingScrollView
, 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.
Well done, Michael!
via ATasty Pixel
No comments:
Post a Comment