iOS MJRefresh上拉加载更多
2015-12-14 20:45
495 查看
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;
}
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;
}
相关文章推荐
- iOS开发之单例模式
- iOS开发 属性(property)和合成(synthesize)
- iOS_开发中遇到的那些问题_3
- iOS_开发中遇到的那些问题_6
- iOS9基础知识(OC)笔记
- ios9基础知识总结(foundation)笔记
- ios9基础知识总结(一)
- iOS 中strong,weak,copy,assign区别
- iOS之如何自适应TableViewCell的高度
- IOS 实现delegate链/广播
- 在手机相册(ios设备相册)中创建相册
- iOS之如何处理TableView cell内容不一致以及cell复用重叠的问题
- iOS 字号转换问题
- 转:iOS利用Runtime自定义控制器POP手势动画
- iOS:友盟SDK第三方登录 分享及友盟统计的使用
- iOS 开发者账号申请(最新)
- IOS那些事------callBack回传的方法
- [转]【IOS-博客】IOS牛人博客一览表
- iOS-在Xcode中使用Git进行源码版本管理(五:忽略更改)
- iOS开发之自定义画板