实现下拉刷新效果 IOS所有版本均可使用

先上图,没图没真相  

下拉刷新效果使用第三方类库

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

posted @ 2012-11-27 22:15  wangzhipeng  阅读(2938)  评论(0编辑  收藏  举报