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

        

    }

  • 相关阅读:
    三种web性能压力测试工具http_load webbench ab小结
    写给加班的IT女生
    C++第9周项目2参考——个人所得税计算器
    C++第9周项目5参考——求一元二次方程的根
    C++程序设计第九周分支结构程序设计上机实践项目
    给编程菜鸟——起跑时的坚持
    C++第9周项目4参考——本月有几天?
    因为涉及到泄密问题,个人博客上SQL优化部分的很多经典案例被删除
    女生真的就不适合学计算机了吗?——答大二女生
    C++第9周项目3参考——利息计算器
  • 原文地址:https://www.cnblogs.com/fan-cong/p/4878414.html
Copyright © 2011-2022 走看看