我在这question中看到CKRefreshControl可以用来替代支持iOS5和iOS6的应用程序的UIRefreshControl。我在Github上找到了代码,但我不知道如何实现它。 John表示只使用相同的代码。但缺少一些东西。 CKRefreshControl代码在哪里?如何实现ckrefreshcontrol来支持ios5?
self.refreshControl = [[UIRefreshControl alloc] init];
谢谢!
我在这question中看到CKRefreshControl可以用来替代支持iOS5和iOS6的应用程序的UIRefreshControl。我在Github上找到了代码,但我不知道如何实现它。 John表示只使用相同的代码。但缺少一些东西。 CKRefreshControl代码在哪里?如何实现ckrefreshcontrol来支持ios5?
self.refreshControl = [[UIRefreshControl alloc] init];
谢谢!
1)增加3班,前缀为您的项目:
- CKParagraphStyle.h and CKParagraphStyle.m
- CKParagraphStyle.h and CKRefreshArrowView.m
- CKRefreshControl.h and CKRefreshControl.m
- CKRefreshControl-Prefix.pch (goes into TableVCs using Refresh).
2)QuartzCore.framework添加到目标库。
3)加入此方法:
-(void)doRefresh:(CKRefreshControl *)sender {
NSLog(@"refreshing");
[self.refreshControl performSelector:@selector(endRefreshing) withObject:nil afterDelay:1.0];
}
最后,使用UIRefreshControl,像往常一样,但选择doRefresh方法:
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(doRefresh:) forControlEvents:UIControlEventValueChanged];
没有具体CKRefreshControl
代码所需比CKRefreshControl源其他本身。当CKRefreshControl
首次发布时,您必须将所有呼叫替换为UIRefreshControl
,并调用CKRefreshControl
,然后根据您是在iOS 5还是在iOS 6+上自动调度到正确的类。
然而,最近John Haitas的贡献,这不再是必要的。相反,简单地编译和链接对CKRefreshControl源代码,使得UIRefreshControl
类可用的定位的iOS 5,其结果的情况下,你可以简单地继续使用[[UIRefreshControl alloc] init]
,它会在iOS自动工作5
你为什么要相信我?因为我是第一个写CKRefreshControl
的人。
您是否阅读过链接到GitHub页面上的README.md文件? https://github.com/instructure/CKRefreshControl/blob/master/README.md – smileyborg 2013-03-09 08:58:45
GitHub存储库还提供了一个如何使用控件的清晰示例:https://github.com/instructure/CKRefreshControl/blob/master /RefreshControlDemo/DefaultRefreshController.m 如果您不明白如何在项目中设置库代码,请下载整个资源库并打开demo Xcode项目以查看它是如何链接的。 – smileyborg 2013-03-09 09:03:34
我觉得有点愚蠢和懒惰。我确实阅读过自述文件。它说的不过是约翰所做的。照常使用UIRefreshControl线。咦?我在许多其他项目中设置了库代码。但我不能看到“图书馆”这个补充。我真的不想通过下载,安装和仔细检查整个存储库,看起来应该是一个简单的答案。 – 2013-03-09 13:13:54