zoukankan      html  css  js  c++  java
  • iOS MJRefresh上拉加载更多

    1.导入MJRefresh包

    2.在类中引入:#import "MJRefresh.h"

    3.添加footerView

    添加加载更多的UI样式:

        MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

        myTableView.footer = footer;

        [footer setTitle:@"正在加载中" forState:MJRefreshStateRefreshing];

        [footer setTitle:@"" forState:MJRefreshStateIdle];

        footer.stateLabel.font = [UIFontsystemFontOfSize:15.0f];

        footer.automaticallyHidden = YES;

    加载数据:

     定义全局变量:int32_t _pageNumber;

        定义loadMoreData方法

    - (void)loadMoreData{

        UIEdgeInsets edge = _tableView.contentInset;

        edge.bottom = 44;

        [UIView animateWithDuration:0.2 animations:^{

            _tableView.contentInset = edge;

        }];

        

        [self loadDataWithPage:_pageNumber];

    }

    4.数据返回处理,排重

            //排重数据

            for (Model *Model1 in resultArray) {

                BOOL isExist = NO;

                for (Model *Model in _publish) {

                    if (Model.positionId == Model1.positionId) {

                        isExist = YES;

                        break;

                    }

                }

                if (!isExist) {

                    [_publish addObject:Model1];

                }

            }

      结束刷新 

            if(_tableView.footer.isRefreshing){

                [_tableView.footer endRefreshing];

            }

            //当数据小于5条,没有下拉刷新

            if (_publishPositions.count < 5) {

                [_tableView.footer noticeNoMoreData];

                _tableView.footer.hidden = YES;

            }

  • 相关阅读:
    第一章:linux命令初步
    请教shell读写XML问题(转)
    讓 BootCamp 下的 Windows XP 也能有 D 硬碟槽(转)
    Linux下的多线程编程(转)
    怎么查看redhat版本
    不透過 Boot Camp 安裝 Windows 7,並切割成多個磁碟槽(转)
    同位语从句用法详解
    更改linux的最大文件描述符限制
    ObjectiveC中 copy, tetain, assign , readonly , readwrite, nonatomic区别
    Linux如何查找文件安装路径
  • 原文地址:https://www.cnblogs.com/biggestfish/p/5041274.html
Copyright © 2011-2022 走看看