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;

            }

  • 相关阅读:
    BZOJ3413: 匹配
    BZOJ5084: hashit
    BZOJ2281: [Sdoi2011]黑白棋
    BZOJ4808: 马
    BZOJ3208: 花神的秒题计划Ⅰ
    BZOJ3714: [PA2014]Kuglarz
    BZOJ2102: [Usaco2010 Dec]The Trough Game
    JZOJ6676. 【2020.06.01省选模拟】查拉图斯特拉如是说 (第二类斯特林数+多项式多点求值)
    LOJ #3217. 「PA 2019」Desant(状压dp)
    JZOJ 5154.【NOI2017模拟6.20】树形图求和 (矩阵树定理)
  • 原文地址:https://www.cnblogs.com/biggestfish/p/5041274.html
Copyright © 2011-2022 走看看