44

I am trying to find an example of placing an element above the Table View outside the normal scrollable region. How would I do this? An example would be what the Tweetie 2 app for the iPhone does to refresh tweets.

Sample code would be extremely helpful.

Michael Celey
  • 12,645
  • 6
  • 57
  • 62
DanO
  • 10,230
  • 4
  • 41
  • 34
  • 1
    If you do use this, be mindful that there is a patent pending for the concept: http://appft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&u=%2Fnetahtml%2FPTO%2Fsearch-adv.html&r=1&f=G&l=50&d=PG01&p=1&S1=20100199180.PGNR.&OS=dn/20100199180&RS=DN/20100199180 – Gavin M. Roy Mar 20 '11 at 18:29
  • Interesting, I know Tweetie did it best, not sure it did this first. Also to note that this question was asked well before the patent was even filed. – DanO Mar 21 '11 at 11:58
  • I believe that when the patent is filed is irrelevant. The criteria is "when did Tweetie 2 release this functionality," and "did anyone else release a product that did the same thing before them?" – Greg Maletic Mar 30 '11 at 21:45
  • 2
    Hate to say this, but it should be criminal to patent a paradigm that users expect to work, especially one like this one. – Moshe Oct 16 '11 at 03:48
  • Software related patents are irrelevant outside USA – kkodev Nov 09 '13 at 21:36

5 Answers5

52

I did find the answer to my own question, for anyone who is interested.

EGOTableViewPullRefresh

I tried this solution and it works great! It is almost identical to the Tweetie Pull Down refresh.

DanO
  • 10,230
  • 4
  • 41
  • 34
  • 4
    I spent a little bit of time on EGOTableViewPullRefresh today and moved the main code into a UITableViewController subclass, it might be easier for some people to implement. http://github.com/jessedc/EGOTableViewPullRefresh – Jessedc Jul 01 '10 at 07:19
  • I think the EGOTableViewPullRefrehsh isn't a very easy solution. But if you can use it: It's the best way ;-) – Fabio Poloni Feb 13 '11 at 14:59
  • I can't find a license on the github site. – titaniumdecoy Apr 27 '11 at 18:58
  • @titaniumdecoy It's in the source: https://github.com/enormego/EGOTableViewPullRefresh/blob/master/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m – JosephH Nov 15 '11 at 09:37
  • I think `EGOTableViewPullRefresh` doesn't supported by author. 2 years no commits. Is `enormego` alive? – Almas Adilbek May 03 '13 at 10:45
20

Here's an alternative to EGOTableViewPullRefresh:

http://blog.leahculver.com/2010/12/iphone-pull-to-refresh.html

Source available on github here:

https://github.com/leah/PullToRefresh

It's slightly easier to use from the developers point of view, though I did go with EGOTableViewPullRefresh in the end as I preferred how it looked.

JosephH
  • 37,173
  • 19
  • 130
  • 154
  • It has a bug when you use it with plain table that has sections. When you scroll up while refreshing, table cells will appear above section header. – Stas Jun 05 '13 at 14:01
4

Start with iOS 6.0, there is a standard control called UIRefreshControl within sdk. apple doc here

Wubao Li
  • 1,728
  • 10
  • 13
3

Here what you can do with iOS 6 and later:

- (void)viewDidLoad { 
    // other initialization
    self.refreshControl = [[UIRefreshControl alloc] init];
    [self.refreshControl addTarget:self
                            action:@selector(myRefresh)
                  forControlEvents:UIControlEventValueChanged];
}

Your refresh method:

- (void)myRefresh {  
    // get refreshed data for table view
}  

You end refreshing in reloadData:

- (void)reloadData {  
    [self.tableView reloadData];  

    // End the refreshing   
    if (self.refreshControl) {  
        [self.refreshControl endRefreshing];  
    }  
}    

Then you are all set!

veducm
  • 5,933
  • 2
  • 34
  • 40
us_david
  • 4,431
  • 35
  • 29
0

You are looking for UIRefreshControl which is available for every UITableViewController - https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIRefreshControl_class/Reference/Reference.html

kkodev
  • 2,557
  • 23
  • 23