iPhone Pull Down Refresh like Tweetie
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 twee开发者_如何学Gots.
Sample code would be extremely helpful.
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.
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.
Start with iOS 6.0, there is a standard control called UIRefreshControl within sdk. apple doc here
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!
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
精彩评论