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;

            }

  • 相关阅读:
    网页版微信无法登录的解决办法
    pycharm运行过程中pycharm控制台和python控制台之间的切换
    随机梯度下降
    K-means聚类
    ubuntu16.04下安装.deb安装包
    过拟合和欠拟合
    从K近邻算法、距离度量谈到KD树、SIFT+BBF算法
    CAJViewer 去除右上角闪动的图标
    C# 的时间戳转换
    网页底部广告 可关闭
  • 原文地址:https://www.cnblogs.com/biggestfish/p/5041274.html
Copyright © 2011-2022 走看看