上拉刷新,下拉加载
Posted kaihaOS
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了上拉刷新,下拉加载相关的知识,希望对你有一定的参考价值。
1.上来加载,下拉刷新数据;
a。导入Refresh文件夹
b。导入头文件:
#import "UIScrollView+MJRefresh.h"
c。添加调用方法
#pragma mark-
#pragma mark-上拉加载,下拉刷新
-(void)setupRefresh
// 1.下拉刷新(进入刷新状态就会调用self的headerRereshing)
[_table addHeaderWithTarget:self action:@selector(headerRereshing)];
//#warning 自动刷新(一进入程序就下拉刷新)
[self.table headerBeginRefreshing];
// // 2.上拉加载更多(进入刷新状态就会调用self的footerRereshing)
// [self.table addFooterWithTarget:self action:@selector(footerRereshing)];
#pragma mark 开始进入刷新状态
- (void)headerRereshing
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 *NSEC_PER_SEC)),dispatch_get_main_queue(), ^
[self.table reloadData];
// (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
[self.table headerEndRefreshing];
);
- (void)footerRereshing
// 2.2秒后刷新表格UI
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^
//刷新表格
[self.table reloadData];
// (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
[self.table footerEndRefreshing];
);
d。在viewdidload里调用方法
[self setupRefresh];
2。图片缓存 a.导入文件夹 SDWebimage; b,引头文件:
#import "UIImageView+WebCache.h"
c。在要用到图片时可以这样调用:
NSURL *url =[NSURL URLWithString:[dic objectForKey:@"pictureUrl"]];
[cell.image setImageWithURL:url];
3.抽屉效果及按钮控制
a。导入文件夹ICSDrawerController。
b。引入头文件:
//#import "ICSDrawerController.h"
//#import "ICSDropShadowView.h"
c。在AppDelegate.m中
LeftViewController *left = [[LeftViewController alloc] init];
UINavigationController *nav5 = [[UINavigationController alloc] initWithRootViewController:left];
RightViewController *right = [[RightViewController alloc] init];
// UINavigationController *nav6 = [[UINavigationController alloc] initWithRootViewController:right];
ICSDrawerController *drawer = [[ICSDrawerController alloc] initWithLeftViewController:nav5 centerViewController:bar];
right.drawer = drawer;
[self.window setRootViewController:drawer];
[drawer release];
[left release];
[right release];
d.在 RightViewController中应该写self.openDrawerButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
[ self.openDrawerButton setTitle:@"点我" forState:UIControlStateNormal];
//[self.openDrawerButton setBackgroundImage:[UIImage imageNamed:@"leftaaaa"] forState:UIControlStateNormal];
[ self.openDrawerButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: self.openDrawerButton];
[ self.openDrawerButton addTarget:self action:@selector(openDrawer:) forControlEvents:UIControlEventTouchUpInside];
[ self.openDrawerButton release];
- (void)openDrawer:(id)sender
if ([str isEqualToString:@"0"])
[self.drawer open];
else
[self.drawer close];
以上是关于上拉刷新,下拉加载的主要内容,如果未能解决你的问题,请参考以下文章
iscroll.js实现上拉刷新,下拉加载更多,应用技巧项目实战
vue10行代码实现上拉翻页加载更多数据,纯手写js实现下拉刷新上拉翻页不引用任何第三方插件
uniapp实现下拉刷新及上拉(分页)加载更多(app,H5,小程序均可使用)
为啥使用mui的上拉刷新下拉加载后在电脑上的刷新加载正常手机上就不正常了