先,沒圖沒真相
下拉重新整理效果使用第三方類庫
ODRefreshControl
例子目錄結構:
Resources 資源檔夾
ThirdPartLib 第三方類庫檔案夾
直接上核心調用代碼,一共只有六句,簡單好用。
設定下拉重新整理的位置
V_animateIndicator *v = [[V_animateIndicator alloc] initWithFrame:CGRectMake(0.f, 0.f, 20.f, 20.f)];ODRefreshControl *refreshControl = [[ODRefreshControl alloc] initInScrollView:self.pTV_main activityIndicatorView:v];[refreshControl addTarget:self action:@selector(dropViewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged];
下拉重新整理後會調用的方法
- (void)dropViewDidBeginRefreshing:(ODRefreshControl *)refreshControl{ double delayInSeconds = 3.0; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ //下拉重新整理後執行的操作 Start [self refreshCell]; //下拉重新整理後執行的操作 End [refreshControl endRefreshing]; });}
PRJ_pullDownRefresh.zip 例子代碼地址:http://ishare.iask.sina.com.cn/f/34837888.html