Sunday, November 6, 2011

Custom UITableView that slides up / down with the keyborad

After working with Apple iPhone SDK within the previous couple of years, i found that the only reason - in my opinion - to use UITableViewController is to take advantage of the default UITableView scrolling when the keyboards rises up and goes down.

But unfortaunty to get this advantage you will have to give up some main features that you probably need in most of your iPhone applications, becuase if you used UITableViewController, the UITableView takes the size of the whole iPhone screen which means the following
1- you can't add other controls to the View
2- you can't customize the UINavigationBar View

After suffering this disability while developing a couple of my apps, i have decided to make my custom TableView that scrolls automatcially when the keyboard slides up, to do so i found it make more sense to make a custom UITextField , to override the start editing method (when the keyboard goes up) and the end editing methods (when the keyboard goes down)



Personally , i don't think my implementation is 100% perfect but at least it fed my needs with my next app, my implementation only supports the portrait view , contains a static variable which something i am not pride of.

You can download the source code from this link , it is recommended to be downloaded from firefox browser

Looking forward for anyone who can take this code and enhance it to support the landscape view / enhance the coding style

No comments:

Post a Comment