0

I've seen in this question that CKRefreshControl can be used as a substitute for UIRefreshControl for apps that support both iOS5 and iOS6. I've found the code on Github, but I don't know how to implement it. John said to just use the same code. But something is missing. Where does the CKRefreshControl code go?

self.refreshControl = [[UIRefreshControl alloc] init];

Thanks!

Community
  • 1
  • 1
Rick_CBR929RR
  • 197
  • 2
  • 15
  • Did you read the README.md on the GitHub page you linked to? https://github.com/instructure/CKRefreshControl/blob/master/README.md – smileyborg Mar 09 '13 at 08:58
  • That GitHub repository also provides a clear example of how to use the control: https://github.com/instructure/CKRefreshControl/blob/master/RefreshControlDemo/DefaultRefreshController.m If you don't understand how to set up the library code in the project, download the entire repository and open the demo Xcode project to see how it's linked in. – smileyborg Mar 09 '13 at 09:03
  • I feel a little stupid and lazy. I did indeed read the README. It says no more than John did. Just use the UIRefreshControl line, as usual. Huh? I've set up library code in a number of other projects. But I can't see "a library" for this to add. I really didn't want to go through downloading, installing and scrutinizing the entire repository when it seems like there SHOULD be a simple answer. – Rick_CBR929RR Mar 09 '13 at 13:13

2 Answers2

2

There is no specific CKRefreshControl code needed other than the CKRefreshControl source itself. When CKRefreshControl was first released you had to replace all calls to UIRefreshControl with calls to CKRefreshControl, and then it automatically dispatched to the correct class based on whether you were on iOS 5 or on iOS 6+.

However, with the recent contributions from John Haitas, that is no longer necessary. Instead, simply compiling and linking against the CKRefreshControl source code makes the UIRefreshControl class available when targeting iOS 5. As a result, you can simply continue to use [[UIRefreshControl alloc] init], and it will automatically work on iOS 5.

Why should you believe me? Because I'm the guy who wrote CKRefreshControl in the first place.

Community
  • 1
  • 1
BJ Homer
  • 48,806
  • 11
  • 116
  • 129
0

1) Add the 3 classes and prefix to your project:

 - CKParagraphStyle.h  and  CKParagraphStyle.m
 - CKParagraphStyle.h  and  CKRefreshArrowView.m
 - CKRefreshControl.h  and  CKRefreshControl.m
 - CKRefreshControl-Prefix.pch  (goes into TableVCs using Refresh).

2) Add the QuartzCore.framework to the target libraries.

3) Add this method:

-(void)doRefresh:(CKRefreshControl *)sender {
        NSLog(@"refreshing");
        [self.refreshControl performSelector:@selector(endRefreshing) withObject:nil afterDelay:1.0];
    }

Finally, use UIRefreshControl, as usual, but select the doRefresh method:

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(doRefresh:) forControlEvents:UIControlEventValueChanged];
TeaCupApp
  • 11,316
  • 18
  • 70
  • 150
Rick_CBR929RR
  • 197
  • 2
  • 15