iOS-MJRefresh框架底层实现原理

本文探讨了iOS应用中MJRefresh框架的底层实现原理,通过在tableView上添加一个负Y值的View来实现下拉刷新效果,监听滚动偏移量更新内容。同时,通过在tableView底部添加footerView并监听其显示状态,实现在内容完全显示时加载更多数据的功能。代码实例已给出,供读者深入理解。
摘要由CSDN通过智能技术生成

直接上代码

**#import "ViewController.h"
#import "MJExtension.h"
#import "AFNetworking.h"
#import "UIView+Frame.h"
#import "TopicItem.h"
@interface ViewController ()
//* 请求管理者 
@property (nonatomic, weak) AFHTTPSessionManager *mgr;
/** 全部的帖子数据 */
@property (nonatomic, strong) NSMutableArray *topics;
/** 用来加载下一页数据 */
@property (nonatomic, copy) NSString *maxtime;
/******** 下拉刷新-header ********/
/** 下拉刷新控件 */
@property (nonatomic, weak) UIView *header;
/** 下拉刷新控件里面的文字 */
@property (nonatomic, weak) UILabel *headerLabel;
/** 是否为"松开立即刷新" */
@property(nonatomic, assign, getter=isWillLoadingNewData) BOOL willLoadingNewData;
/** 是否为"正在刷新" */
@property(nonatomic, assign, getter=isLoadingNewData) BOOL loadingNewData;
/******** 下拉刷新-header ********/
/******** 上拉刷新-footer ********/
/** 上拉刷新控件 */
@property (nonatomic, weak) UIView *footer;
/** 上拉刷新控件里面的文字 */
@property (nonatomic, weak) UILabel *footerLabel;
/** 是否正在加载更多数据 */
@property(nonatomic, assign, getter=isLoadingMoreData) BOOL loadingMoreData;
/******** 上拉刷新-footer ********/
@end
@implementation ViewController
#pragma mark - 懒加载
- (AFHTTPSessionManager *)mgr
{
    if (!_mgr) {
        _mgr = [AFHTTPSessionManager manager];
    }
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值