I recently implemented pull to re开发者_JS百科fresh here: https://github.com/leah/PullToRefresh. It kind of works however it gets stuck with a spinning activity indicator. Their is also no text to the right of the arrow. What am I doing wrong? Thanks!
Without code there's not much anyone can say, but maybe try a different implementation of Pull To Refresh, like the enormego (EGO) version, the code is at github, here
It's used in the Facebook app so it definitely works.
Apple has introduced UIRefreshControl in iOS6. You can integrate it in your UITableViewController using
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize Refresh Control
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
// Configure Refresh Control
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
// Configure View Controller
[self setRefreshControl:refreshControl];
}
the refresh: method will trigger the update and you can stop it in your API callback using:
[(UIRefreshControl *)sender endRefreshing];
I am new to iOS development and I was trying to implement the pull to refresh in iOS 6. Well looking for a solution, I stumbled across this blog post and found it to be very helpful, http://www.intertech.com/Blog/Post/iOS-6-Pull-to-Refresh-(UIRefreshControl).aspx. It lays out the steps to implementing pull to refresh in a way that is easy to follow. Anyone looking to do this themselves in iOS 6 should check out the blog.
The UIRefreshControl is only useable with a Table View currently. There are a few steps to follow to successfully add a refresh control:
1. Create a callback method to handle your refresh logic. The callback method should be invoked when a user pulls down on the table view. The signarture of the method should take one parameter: a pointer to the UIRefreshControl.
Note: Steps 2-4 are all done within the Table View Controller’s viewDidLoad method.
2. Instantiate the UIRefreshControl with a basic "alloc/init".
3. Connect an action to the refresh control to invoke your callback method when the ValueChange event is fired.
4. Add the refresh control to the Table View Controller's "refreshControl" property.
I prefer the EGO implementation than the leah one because it does not require a subclass of your view controller. The original EGO one in github is a bit of a mess with no .gitnore file and lots of .DS_Store files added unnecessarily. Take a look at some of the many forks and pick one.
The "emreberge" fork looks like a good version, better file organisation and documentation too!
https://github.com/emreberge/EGOTableViewPullRefresh
I found this library very useful, fancy and up-to-date: https://github.com/Yalantis/Pull-to-Refresh.Rentals-iOS
(Recommendations from other answers seem old and not maintained)
Now, with newer versions of iOS than the above stated iOS 5 you can use: UIRefreshControl.
There is a really good tutorial on creating your own custom pull to refresh for your iOS Application: http://ios-blog.co.uk/tutorials/how-to-add-a-custom-pull-to-refresh-in-your-ios-application/
You can use : https://github.com/ngocbinh02/httablekit
Support iOS 5.0 or later
Pull to refresh tableview
import <HTTableKit/TableKit>
....
//like UIRefreshControll
[tableview setPullToRefreshControlType:UITableViewRefreshControlTypeSystem];
[tableview setPullToRefreshModeEnable:YES beginHandler:^{
// to do here when pulling to refresh
}];
Dismiss pull to refresh tableview
import <HTTableKit/TableKit>
....
[tableview dismissPullToRefreshEndHandler:^{
// to do here when dismissing
}];
Here's our tutorial on Custom Pull-to-Refresh controls, with code for Objective-C and Swift: http://www.jackrabbitmobile.com/design/ios-custom-pull-to-refresh-control/
To add additional text or images, as you mentioned, add them into self.refreshLoadingView
in the setupRefreshControl
or scrollViewDidScroll
methods (from the tutorial).
Let me know if that helps!
精彩评论