Add Pull to Refresh feature to your iOS App

Views: 24222 | Add Comments

With CocoaUI’s ITable view controller, you can easily add Pull to Refresh feature to your iOS App, you can add “Pull Down to Refresh” and “Pull Up to Load More” at the same time.

    IRefreshControl *header = [[IRefreshControl alloc] init];
    self.headerRefreshControl = header;
    IRefreshControl *footer = [[IRefreshControl alloc] init];
    self.footerRefreshControl = footer;

That’s it, put this code in your view controller’s viewDidLoad method, then your App has the ability of “Pull to Refresh”.

To deal with refresh event, you will have to write an event handler as:

- (void)onRefresh:(IView *)view state:(IRefreshState)state{
    if(state == IRefreshBegin){
        // refresh
        if(view == self.headerRefreshControl){
            [self clear];
        // load more
        if(view == self.footerRefreshControl){
        [self reload];
        [self endRefresh:view]; // end loading indicator

Here’s the screen shots:

iOS UITableView pull to refresh-1

iOS UITableView pull to refresh-2

Posted by ideawu at 2015-02-02 14:41:19 Tags: ,

Leave a Comment