关于页面的下拉刷新,和上拉加载 --- > collectionView ,tableView
2015-10-14 19:21
337 查看
1 )上拉加载 MJRefreh三方库
-(void)headAdd
{
NSInteger num = 0;
NSString *str = [NSString stringWithFormat:@"http://open4.bantangapp.com/topic/list",++num];
[self.collectionView addFooterWithCallback:^{
[ReadAsync readAsyncWithwebStr:str parmater:nil block:^(NSData *data) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSDictionary *dic1 = [dic objectForKey:@"data"];
NSArray *array = [dic1 objectForKey:@"topic"];
for (NSDictionary *dictionary in array) {
ReadModel *model = [[ReadModel alloc]init];
[model setValuesForKeysWithDictionary:dictionary];
[self.imageArray addObject:model];
}
[self.collectionView reloadData];
}];
[self.collectionView footerEndRefreshing];
}];
}
2). 下拉刷新 ;在数据解析的block里移除存放数据的数组里的元素;下拉刷新只舒心第一页的数据
-(void)footRefesh
{
// 添加下拉刷新头部控件
[self.collectionView addHeaderWithCallback:^{
[ReadAsync readAsyncWithwebStr:@“http://baidu.com“ parmater:nil block:^(NSData *data) {
[self.imageArray removeAllObjects];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSDictionary *dic1 = [dic objectForKey:@"data"];
NSArray *array = [dic1 objectForKey:@"topic"];
for (NSDictionary *dictionary in array) {
ReadModel *model = [[ReadModel alloc]init];
[model setValuesForKeysWithDictionary:dictionary];
[self.imageArray addObject:model];
}
[self.collectionView reloadData];
}];
// 结束刷新
[self.collectionView headerEndRefreshing];
}];
#pragma mark --自动刷新(一进入程序就下拉刷新)
[self.collectionView headerBeginRefreshing];
}
-(void)headAdd
{
NSInteger num = 0;
NSString *str = [NSString stringWithFormat:@"http://open4.bantangapp.com/topic/list",++num];
[self.collectionView addFooterWithCallback:^{
[ReadAsync readAsyncWithwebStr:str parmater:nil block:^(NSData *data) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSDictionary *dic1 = [dic objectForKey:@"data"];
NSArray *array = [dic1 objectForKey:@"topic"];
for (NSDictionary *dictionary in array) {
ReadModel *model = [[ReadModel alloc]init];
[model setValuesForKeysWithDictionary:dictionary];
[self.imageArray addObject:model];
}
[self.collectionView reloadData];
}];
[self.collectionView footerEndRefreshing];
}];
}
2). 下拉刷新 ;在数据解析的block里移除存放数据的数组里的元素;下拉刷新只舒心第一页的数据
-(void)footRefesh
{
// 添加下拉刷新头部控件
[self.collectionView addHeaderWithCallback:^{
[ReadAsync readAsyncWithwebStr:@“http://baidu.com“ parmater:nil block:^(NSData *data) {
[self.imageArray removeAllObjects];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSDictionary *dic1 = [dic objectForKey:@"data"];
NSArray *array = [dic1 objectForKey:@"topic"];
for (NSDictionary *dictionary in array) {
ReadModel *model = [[ReadModel alloc]init];
[model setValuesForKeysWithDictionary:dictionary];
[self.imageArray addObject:model];
}
[self.collectionView reloadData];
}];
// 结束刷新
[self.collectionView headerEndRefreshing];
}];
#pragma mark --自动刷新(一进入程序就下拉刷新)
[self.collectionView headerBeginRefreshing];
}
相关文章推荐
- Buffett saying
- 【iOS】Xib的使用与File'Owner总结
- C++编程细节总结
- 1002. A+B for Polynomials
- Linux命令执行顺序控制与管道
- 深入浅出-iOS程序性能优化
- PhoneGap插件开发 js与Java之间的交互例子 详解
- iOS解决http请求不能使用问题
- python string转为dict --- json.loads
- 黑马程序员——Java基础语法---流程控制语句
- JS连续滚动幻灯片:原理与实现
- 低功耗FPGA的研究
- linux shell 字符串操作(长度,查找,替换)详解
- 软件测试总结
- android 5.0关机流程-kernel层
- Android采用canvas绘制各种图形
- EMC现场测试-EFT、ESD、Surge和场辐射
- ANSI、UNICODE、UTF-8编码格式相互之间转换
- JavaWeb监听器
- KSImageNamed 安装后无效解决方法 亲测有用