Wednesday, February 9, 2011

iPhone Pull to Refresh

There are several ways to implement Pull-toRefresh on iPhones. The best method that I have found so far is Leah Culver's technique. I especially like it because all you have to do is add PullRefreshTableViewController.h and PullRefreshTableViewController.m to your project and subclass them in your UITableViewController. You should also add the the arrow.png image included with the code or replace it with your own image. This technique should be included in Apple's Sample code.

iPhone Pull to Refresh

Ever since Tweetie 2, the pull-to-refresh paradigm has been a hot feature for iPhone applications. The idea is that you can pull down on a list of items to refresh them. This saves you from needing some sort of "refresh" or "reload" button. Nice!

For the upcoming V2 of the Plancast iPhone app we really wanted to replace the current "reload" toolbar item with the pull-to-refresh style. However, the existing open source pull to refresh examples such as Three20's Pull to Reload and EGOTableViewPullRefresh are a little too complicated for my taste. Heck - this should only require one file!

So here it is... a very simple pull-to-refresh:


All you need to do is add the .h and .m files to your project and subclass them. I've added a bit of a hack to make pull-to-refresh work with tables that have multiple sections (like Plancast).

There's even a built-in demo so you can try it out right away.

Refresh-1 Refresh-2 Refresh-3

see iPhone Pull to Refresh - Leah Culver's Blog

No comments:

Post a Comment

Popular Posts