Edited at

ISRefreshControl(iOS4-compatible UIRefreshControl)

More than 5 years have passed since last update.


environment

Xcode: 4.6.3

Base SDK: iOS 6.1

Deployment Target: 5.1


ISRefreshControl


Install from GitHub


zsh

$ cd workspace

$ git clone https://github.com/ishkawa/ISMethodSwizzling.git
$ git clone https://github.com/ishkawa/ISRefreshControl.git


  1. Drag ISMethodSwizzling/ISMethodSwizzling/ & Drop Xcode Project Navigator

  2. Destination "Copy items into destination group's folder (if needed)" checked

  3. Folders "Create groups for any added folders" checked

  4. Add to targets main project checked

  5. Do the same above action for ISRefreshControl


For Example


uitableviewcontroller.m

#import "ISRefreshControl.h"


- (void)viewDidLoad
{
self.refreshControl = (id)[[ISRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refreshTableView:) forControlEvents:UIControlEventValueChanged];
}

- (void)refreshTableView:(ISRefreshControl *)refreshControl
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
sleep(1);
dispatch_async(dispatch_get_main_queue(), ^{
[refreshControl endRefreshing];
});
});
}



uiviewcontroller.m

#import "ISRefreshControl.h"


- (void)viewDidLoad
{
ISRefreshControl *refreshControl = [[ISRefreshControl alloc] init];
[self.tableView addSubview:refreshControl];
[refreshControl addTarget:self action:@selector(refreshTableView:) forControlEvents:UIControlEventValueChanged];
}