美文网首页iOS 开发 iOS Development
基础知识-->>系统下拉刷新UIRefreshCon

基础知识-->>系统下拉刷新UIRefreshCon

作者: MrBrave丶彬彬 | 来源:发表于2016-09-27 10:05 被阅读200次

最近在研究下拉刷新的一些问题,先给大家介绍下系统的下拉刷新。。如果问题望指点出来。。


1、UIRefreshControl的简单用法


#######效果图

1.gif

#######代码《很简单的额几句话》

    //添加刷新控件 UIRefreshControl继承UIControl
    UIRefreshControl *control=[[UIRefreshControl alloc]init];
    //加载文字
    control.attributedTitle = [[NSAttributedString alloc] initWithString:@"努力赚钱中。。。。"];
    //设置菊花颜色
    control.tintColor = [UIColor redColor];
    //实现方法 《实现数据得请求》
    [control addTarget:self action:@selector(refreshStateChange:) forControlEvents:UIControlEventValueChanged];
    //加到tableView上
    [self.tableView addSubview:control];

#######实现方法


/** 系统下拉刷新 */
- (void)refreshStateChange:(UIRefreshControl *)control
{
    [[HttpRequestTool shareManager] requestWithUrlString:@"http://www.duitang.com/napi/topic/list/by_tags" parameters:nil successBlock:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dataDict = [responseObject objectForKey:@"data"];
        NSArray * object_list = [dataDict objectForKey:@"object_list"];
        
        for (NSDictionary * objDict in object_list) {
            JiChuModel * model = [JiChuModel jiChuModelDict:objDict];
            JiChuFrameModel * frameModel = [[JiChuFrameModel alloc]init];
            frameModel.model  = model;
            [_dataArray addObject:frameModel];
        }
        [self.tableView reloadData];
        //结束刷新
        [control endRefreshing];
    } failureBlock:^(AFHTTPRequestOperation *operation, NSError *error) {
      //结束刷新
       [control endRefreshing];
  
    }];

}


靠山山会倒,靠水水会流,靠自己永远不倒。。。
2016年09月27日 未完待续。。

相关文章

网友评论

    本文标题:基础知识-->>系统下拉刷新UIRefreshCon

    本文链接:https://www.haomeiwen.com/subject/ylecyttx.html