iOS 上拉刷新和下拉加在更多(第三方框架EGOTableViewPullRefresh)
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
#import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; self.window.rootViewController = [[RootViewController alloc] init]; [self.window makeKeyAndVisible];
return YES;
} @end
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
// EGOTableViewPullRefresh框架的链接: http://pan.baidu.com/s/1qWVhVPy 密码: 2p7k #import "RootViewController.h"
#import "PullTableView.h"
@interface RootViewController ()<PullTableViewDelegate,UITableViewDataSource,UITableViewDelegate>
{
PullTableView *_tableView;
NSMutableArray *data;
int page;
}
@end @implementation RootViewController - (void)viewDidLoad {
[super viewDidLoad];
//初始化数组
data = [[NSMutableArray alloc] init];
page = ;
//初始化_tableView
_tableView = [[PullTableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStylePlain];
_tableView.dataSource = self;
_tableView.delegate = self;
//设置pullDelegate代理
_tableView.pullDelegate = self;
[self.view addSubview:_tableView];
//请求数据
[self requestDataWithPage:page];
}
/**
* 数据
*/
- (void)requestDataWithPage:(int)number{
int count = number * ;
for (int i = ; i < count; i++) {
[data addObject:[NSString stringWithFormat:@"%d",i]];
}
}
#pragma mark -- tableview 数据源配置 --
//返回多少个区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return ;
}
//返回相应的区的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return data.count;
}
//返回cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return ;
}
// 配置cell的数据
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
//注意:使用数据源时要进行判断(data.count != 0),否则程序会崩溃
if (data.count != ) {
cell.textLabel.text = data[indexPath.row];
}
return cell;
}
#pragma mark -- PullTableView 代理 --
- (void)pullTableViewDidTriggerRefresh:(PullTableView *)pullTableView{
[self performSelector:@selector(refresh) withObject:nil afterDelay:0.3f];
} - (void)pullTableViewDidTriggerLoadMore:(PullTableView *)pullTableView{
[self performSelector:@selector(loadmore) withObject:nil afterDelay:0.3f];
}
/**
* 刷新
*/
- (void)refresh{
[self clearData];
page = ;
[self requestDataWithPage:page];
_tableView.pullLastRefreshDate = [NSDate date];
//停止刷新
_tableView.pullTableIsRefreshing = NO;
[_tableView reloadData];
}
/**
* 加载更多
*/
- (void)loadmore{
[self clearData];
page++;
[self requestDataWithPage:page];
_tableView.pullTableIsLoadingMore = NO;
[_tableView reloadData];
}
/**
* 清空数组
*/
- (void)clearData{
[data removeAllObjects];
} @end
iOS 上拉刷新和下拉加在更多(第三方框架EGOTableViewPullRefresh)的更多相关文章
- PullToRefreshGridView上拉刷新,下拉加载
PullToRefreshGridView上拉刷新,下拉加载 布局: <?xml version="1.0" encoding="utf-8"?> ...
- iscroll.js实现上拉刷新,下拉加载更多,应用技巧项目实战
上拉刷新,下拉加载更多...仿原生的效果----iscroll是一款做滚动效果的插件,具体介绍我就不废话,看官方文档,我只写下我项目开发的一些用到的用法: (如果不好使,调试你的css,想必是个很蛋疼 ...
- vux (scroller)上拉刷新、下拉加载更多
1)比较关键的地方是要在 scroller 组件上里加一个 ref 属性 <scroller :lockX=true height="-170" :pulldown-conf ...
- iOS--MJRefresh的使用 上拉刷新和下拉加载
1.一般使用MJRefresh 来实现上拉刷新和下拉加载功能 2.MJRefresh 下载地址:https://github.com/CoderMJLee/MJRefresh 3. MJRefresh ...
- 【转】vux (scroller)上拉刷新、下拉加载更多
1)比较关键的地方是要在 scroller 组件上里加一个 ref 属性 <scroller :lockX="true" height="-170" :p ...
- Android PullToRefreshListView上拉刷新和下拉刷新
PullToRefreshListView实现上拉和下拉刷新有两个步骤: 1.设置刷新方式 pullToRefreshView.setMode(PullToRefreshBase.Mode.BOTH) ...
- ListView(2)最简单的上拉刷新,下拉刷新
最简单的上拉刷新和下拉刷新,当listview滚动到底部时向上拉刷新数据.当listview滚动到最顶部时下拉刷新. 图1,上拉刷新 图2,下拉刷新 1,设置lisview,加载heade ...
- android ListView的上部下拉刷新下部点击加载更多具体实现及拓展
android ListView的上部下拉刷新下部点击加载更多具体实现及拓展 ListView下拉刷新,上拉自动加载更多 下拉刷新以及加载更多
- ListView(2)最简单的上拉刷新、下拉刷新代码
效果 最简单的上拉刷新和下拉刷新,当listview滚动到底部时向上拉刷新数据.当listview滚动到最顶部时下拉刷新. 图1,上拉刷新 图2,下拉刷新 1.设置lisview 加载he ...
随机推荐
- QQ、淘宝、阿里旺旺在线网页链接代码及详解 很实用
你可直接到官网去生成代码,简单.方便,相信都能上网的你,对这不会有难度的,认识字的就行,赶紧去吧! 1.阿里旺旺官网: http://page.1688.com/html/wangwang/dow ...
- 一些Discuz!代码
首行缩进2字符 [code][p=20, 2, left]首行缩进2字符[/p][/code]
- LR调用动态链接库DLL
什么是动态库? 动态库一般又叫动态链接库(DLL),是Dynamic Link Library 的缩写形式,DLL是一个包含可由多个程序同时使用的代码和数据的库. 动态链接提供了一种方法 ,使进程可以 ...
- DOM下的节点属性和操作小结
属性: 1 .nodeName 节点名称,相当于tagName.属性节点返回属性名,文本节点返回#text.nodeName,是只读的. 2 .nodeType 值:1,元素节点:2,属性节点:3,文 ...
- mysql 存储过程 php版本
<?php /** * PHP操作Mysql存储过程示例 * * @author flyer0126 * @date 2011-12-23 * */ //配置数据库连接信息 $hostname ...
- IOS常见的三种回调方法介绍
认识下三种IOS常见的回调模式. 代理模式作为IOS中最常见的通讯模式,代理几乎无处不在. 这里有一个数组,我们首先通过代理的方式将数组传递到其他方法中去. 设置协议及方法 @protocol Cal ...
- hadoop、hbase、hive、zookeeper版本对应关系
本文引用自:http://www.aboutyun.com/blog-61-62.html 最新版本: hadoop和hbase版本对应关系: Hbase Hadoop 0.92.0 1.0.0 ...
- Java实验报告二:Java面向对象程序设计
Java实验报告二:Java面向对象程序设计 ...
- sqlserver 计算 百分比
,),))+'%' As 百分比 NUMERIC(P,S) P的默认值是:38 S的默认值是:-84~127 numeric(a,b)函数有两个参数,前面一个为总的位数,后面一个参数是小数点后的位数, ...
- php安装xcache (5.4)
安装环境centOS6.3APACHE:apache-2.4.4PHP:5.4.13 1.安装xchache: 代码如下: # wget http://xcache.lighttpd.net/pub/ ...