zoukankan      html  css  js  c++  java
  • 关于页面的下拉刷新,和上拉加载 --- > collectionView ,tableView

    1 )上拉加载 MJRefreh三方库

    -(void)headAdd

    {

        NSInteger num = 0;

        NSString *str = [NSString stringWithFormat:@"http://open4.bantangapp.com/topic/list",++num];

         [self.collectionView addFooterWithCallback:^{

            

            [ReadAsync readAsyncWithwebStr:str  parmater:nil block:^(NSData *data) {

                    

                    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];

                    

                    NSDictionary *dic1 = [dic objectForKey:@"data"];

                    NSArray *array = [dic1 objectForKey:@"topic"];

                    for (NSDictionary *dictionary in array) {

                        

                        ReadModel *model = [[ReadModel alloc]init];

                        [model setValuesForKeysWithDictionary:dictionary];

                        [self.imageArray addObject:model];

                        

                    }

                    [self.collectionView reloadData];

                    

                }];

                

             

               [self.collectionView footerEndRefreshing];

                

       

        }];

        

        

    }

    2). 下拉刷新 ;在数据解析的block里移除存放数据的数组里的元素;下拉刷新只舒心第一页的数据

    -(void)footRefesh

    {

        // 添加下拉刷新头部控件

       [self.collectionView  addHeaderWithCallback:^{     

        [ReadAsync readAsyncWithwebStr:@“http://baidu.com“  parmater:nil block:^(NSData *data) {

            

            [self.imageArray removeAllObjects];

            NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];

            

            NSDictionary *dic1 = [dic objectForKey:@"data"];

            NSArray *array = [dic1 objectForKey:@"topic"];

            for (NSDictionary *dictionary in array) {

                

                ReadModel *model = [[ReadModel alloc]init];

                [model setValuesForKeysWithDictionary:dictionary];

                [self.imageArray addObject:model];

                

            }

            [self.collectionView reloadData];

            

        }];

                // 结束刷新

        [self.collectionView headerEndRefreshing];

                

            }];

     #pragma mark  --自动刷新(一进入程序就下拉刷新)

        [self.collectionView headerBeginRefreshing];

        

    }

  • 相关阅读:
    BlocksKit block从配角到主角—oc通往函数式编程之路--oc rx化?
    使用NSProxy和NSObject设计代理类的差异
    面向发布(部署)编程—热修复、动态库与补丁
    解释器就是虚拟机
    动态和多态的本质是对不确定性的解释机制
    c+多态的本质:编译器维护了类型信息同时插入了解释执行机制
    ios Aspects面向切面沉思录—面向结构编程—面向修改记录编程—面向运行时结构编程—元编程?
    知行合一的方法论
    面向运行时结构信息编程
    c++、oc、swift初步评价
  • 原文地址:https://www.cnblogs.com/fan-cong/p/4878414.html
Copyright © 2011-2022 走看看