- 浏览: 2468491 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
jsntghf:
peio 写道这个怎么运行?Ruby On Rails的环境搭 ...
多文件上传之uploadify -
peio:
这个怎么运行?
多文件上传之uploadify -
往事如烟1:
我的项目是自己init了一个原始的project,之后将ver ...
React Native热部署之CodePush -
jsntghf:
往事如烟1 写道我按照你的说明进行,发现app退出之后,在进入 ...
React Native热部署之CodePush -
往事如烟1:
我按照你的说明进行,发现app退出之后,在进入不正确,请问是什 ...
React Native热部署之CodePush
以前,写了一篇文章:下拉刷新的实现,只讲到了下拉刷新的功能,这篇文章描述了下拉刷新以及上拉加载更多的功能。
这里只列出核心功能的代码,其他的代码请参考附件。
DemoTableViewController.h
#import <UIKit/UIKit.h> #import "STableViewController.h" @interface DemoTableViewController : STableViewController { NSMutableArray *items; } @end
DemoTableViewController.m
#import "DemoTableViewController.h" #import "DemoTableHeaderView.h" #import "DemoTableFooterView.h" @interface DemoTableViewController () - (void) addItemsOnTop; - (void) addItemsOnBottom; - (NSString *) createRandomValue; @end @implementation DemoTableViewController - (void) viewDidLoad { [super viewDidLoad]; self.title = @"STableViewController Demo"; [self.tableView setBackgroundColor:[UIColor lightGrayColor]]; NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DemoTableHeaderView" owner:self options:nil]; DemoTableHeaderView *headerView = (DemoTableHeaderView *)[nib objectAtIndex:0]; self.headerView = headerView; nib = [[NSBundle mainBundle] loadNibNamed:@"DemoTableFooterView" owner:self options:nil]; DemoTableFooterView *footerView = (DemoTableFooterView *)[nib objectAtIndex:0]; self.footerView = footerView; items = [[NSMutableArray alloc] init]; for (int i = 0; i < 10; i++) [items addObject:[self createRandomValue]]; } #pragma mark - Pull to Refresh - (void) pinHeaderView { [super pinHeaderView]; DemoTableHeaderView *hv = (DemoTableHeaderView *)self.headerView; [hv.activityIndicator startAnimating]; hv.title.text = @"Loading..."; } - (void) unpinHeaderView { [super unpinHeaderView]; [[(DemoTableHeaderView *)self.headerView activityIndicator] stopAnimating]; } - (void) headerViewDidScroll:(BOOL)willRefreshOnRelease scrollView:(UIScrollView *)scrollView { DemoTableHeaderView *hv = (DemoTableHeaderView *)self.headerView; if (willRefreshOnRelease) hv.title.text = @"Release to refresh..."; else hv.title.text = @"Pull down to refresh..."; } - (BOOL) refresh { if (![super refresh]) return NO; [self performSelector:@selector(addItemsOnTop) withObject:nil afterDelay:2.0]; return YES; } #pragma mark - Load More - (void) willBeginLoadingMore { DemoTableFooterView *fv = (DemoTableFooterView *)self.footerView; [fv.activityIndicator startAnimating]; } - (void) loadMoreCompleted { [super loadMoreCompleted]; DemoTableFooterView *fv = (DemoTableFooterView *)self.footerView; [fv.activityIndicator stopAnimating]; if (!self.canLoadMore) { fv.infoLabel.hidden = NO; } } - (BOOL) loadMore { if (![super loadMore]) return NO; [self performSelector:@selector(addItemsOnBottom) withObject:nil afterDelay:2.0]; return YES; } #pragma mark - Dummy data methods - (void) addItemsOnTop { for (int i = 0; i < 3; i++) [items insertObject:[self createRandomValue] atIndex:0]; [self.tableView reloadData]; [self refreshCompleted]; } - (void) addItemsOnBottom { for (int i = 0; i < 5; i++) [items addObject:[self createRandomValue]]; [self.tableView reloadData]; if (items.count > 50) self.canLoadMore = NO; else self.canLoadMore = YES; [self loadMoreCompleted]; } - (NSString *) createRandomValue { NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; return [NSString stringWithFormat:@"%@ %@", [dateFormatter stringFromDate:[NSDate date]], [NSNumber numberWithInt:rand()]]; } #pragma mark - Standard TableView delegates - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return items.count; } - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [items objectAtIndex:indexPath.row]; return cell; } @end
- Demo.zip (26.6 KB)
- 下载次数: 281
评论
2 楼
wwwang89
2013-04-07
楼主,你的demo里面 的代码跟博客里面的不一样,群殴确信你上传错位了,,是你前一篇博客 的demo,请楼主在重新上传一次,O(∩_∩)O谢谢
1 楼
nyh1006
2013-03-23
最好加上注释!
发表评论
-
Error watching file for changes: EMFILE
2016-12-15 11:57 1233执行npm start后报错: Error watc ... -
CocoaPods升级1.1.1报错
2016-12-15 08:39 736ERROR: While executing gem .. ... -
Visual Studio Code运行React Native报错
2016-06-13 09:43 1550React Native:0.27.2 React:15 ... -
React Native 0.27.2编译报错this._nativeModule.addListener is not a function
2016-06-12 15:21 3780React Native:0.27.2 React:15 ... -
Unable to resolve module ReactDefaultPerf from
2016-06-02 13:04 2729package.json信息如下: "reac ... -
React Native 0.26.2编译报错Undefined symbols for architecture x86_64
2016-05-26 11:15 1938React Native:0.26.2 React:15. ... -
Failed to update auto layout status: Failed to load designables from path (null)
2016-04-05 22:11 1662确保CocoaPods是0.36.1以上版本,然后在podf ... -
集成微信支付出现Undefined symbols for architecture x86_64错误
2016-03-21 13:22 1677Undefined symbols for architec ... -
React Native热部署之CodePush
2016-01-10 22:27 6110本文使用的环境是Mac OS 10.11.1、Xcode ... -
浅谈React Native中的FlexBox布局
2015-11-17 18:38 4264React Native通过一个基于FlexBox的布局引 ... -
React Native之构建一个简单的列表页
2015-10-23 14:45 2081本文中我们将创建一个简单的电影应用,这个应用将从Rotten ... -
React Native之环境搭建
2015-10-20 16:30 1386本文使用的环境是Mac O ... -
获取图片属性的方法
2015-10-18 20:43 3058很多时候我们需要获 ... -
NSCache的下标用法
2015-09-18 00:19 1161NSCache类和NSDictionary类很相似,也提供 ... -
如何给category添加属性
2015-08-16 10:41 637主要是使用了runtime中的associative机制。 ... -
UITableView的两种重用Cell方法的区别
2015-08-10 13:07 16055UITableView中有两种重用Cell的方法: - ... -
SDImageCache.m报错Unused variable 'fileName'
2015-08-04 21:56 1126GCC手册中的相关解释: unused:This att ... -
Swift调用Objective-C
2015-07-13 23:33 1171Swift调用Objective-C需要一个名为<工程 ... -
使用GCD实现倒计时
2015-07-24 21:47 1042__block int timeout = 60; // ... -
导航栏加分割线的实现
2015-07-01 22:00 1679self.view.backgroundColor = [U ...
相关推荐
dropload.js是一款jQuery移动端下拉刷新、上拉加载更多插件。dropload.js可以依赖于jquery或Zepto,实现移动端常见的下拉刷新和上拉加载更多功能。
ExpandSwipeRefreshLayout扩展了SwipeRefreshLayout的功能,使得同时具有下拉刷新与上拉加载更多。
Materal风格之下的recycleView下拉刷新以及上拉加载更多,这个是自己遇到的问题然后再网上综合参考他人的一种实现方式
RecyclerView搭配SwipeRefreshLayout和BaseQuickAdapter万能适配器实现下拉刷新和上拉加载更多
安卓不错的下拉刷新,上拉加载更多的框架,可以结合与RecyclerView使用。
微信小程序的下拉刷新,上拉加载更多功能,新手可以很好的参考。
android下拉刷新上拉加载更多android下拉刷新上拉加载更多android下拉刷新上拉加载更多android下拉刷新上拉加载更多
自定义listview下拉刷新上拉加载更多以及与google官方的下拉刷新结合使用
listview,gridview,scrollview下拉刷新和上拉加载更多
自定义listview下拉刷新上拉加载更多以及google官方的下拉刷新
顶部导航(支持左右滑,下拉刷新,上拉加载更多,返回顶部,加载动画)
通过微信小程序的滑块视图容器swiper及swiper-item实现tab切换功能,同时实现下拉刷新,上拉加载更多功能。
内容概要:uniapp实现下拉刷新及上拉加载更多的完整代码(app,H5,小程序均可使用),下载后解压,使用HBuilder导入项目即可运行。 适合人群:少许编程基础人员即可. 适应场景:需要使用uniapp开发移动端时,涉及...
找下拉刷新,上拉加载的demo找了好久,踩找到这个相对完美的。所以分享给大家。 同时也将GitHub上的一个开源的下拉刷新,上拉加载的ListView稍稍改良了一下! 原始代码地址:...
vue移动端列表组件,支持下拉刷新,上拉加载更多
预先声明:下拉刷新是网上另一位大神发出来的源码,本彩笔只是仿照大神的源码自己写了上拉加载更多。然后把侧滑删除也揉了进去。 最后请各位注意ListView的上拉,下拉和侧滑都是经过测试可用的。但是...
RecyclerView实现下拉刷新和上拉加载更多功能
实现基本UITableView的下拉刷新和上拉加载更多的功能