2013-03-09 53 views
0

我在這question中看到CKRefreshControl可以用來替代支持iOS5和iOS6的應用程序的UIRefreshControl。我在Github上找到了代碼,但我不知道如何實現它。 John表示只使用相同的代碼。但缺少一些東西。 CKRefreshControl代碼在哪裏?如何實現ckrefreshcontrol來支持ios5?

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

謝謝!

+0

您是否閱讀過鏈接到GitHub頁面上的README.md文件? https://github.com/instructure/CKRefreshControl/blob/master/README.md – smileyborg 2013-03-09 08:58:45

+0

GitHub存儲庫還提供了一個如何使用控件的清晰示例:https://github.com/instructure/CKRefreshControl/blob/master /RefreshControlDemo/DefaultRefreshController.m 如果您不明白如何在項目中設置庫代碼,請下載整個資源庫並打開demo Xcode項目以查看它是如何鏈接的。 – smileyborg 2013-03-09 09:03:34

+0

我覺得有點愚蠢和懶惰。我確實閱讀過自述文件。它說的不過是約翰所做的。照常使用UIRefreshControl線。咦?我在許多其他項目中設置了庫代碼。但我不能看到「圖書館」這個補充。我真的不想通過下載,安裝和仔細檢查整個存儲庫,看起來應該是一個簡單的答案。 – 2013-03-09 13:13:54

回答

0

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]; 
2

沒有具體CKRefreshControl代碼所需比CKRefreshControl源其他本身。當CKRefreshControl首次發佈時,您必須將所有呼叫替換爲UIRefreshControl,並調用CKRefreshControl,然後根據您是在iOS 5還是在iOS 6+上自動調度到正確的類。

然而,最近John Haitas的貢獻,這不再是必要的。相反,簡單地編譯和鏈接對CKRefreshControl源代碼,使得UIRefreshControl類可用的定位的iOS 5,其結果的情況下,你可以簡單地繼續使用[[UIRefreshControl alloc] init],它會在iOS自動工作5

你爲什麼要相信我?因爲我是第一個寫CKRefreshControl的人。

相關問題