#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)的更多相关文章

  1. PullToRefreshGridView上拉刷新,下拉加载

    PullToRefreshGridView上拉刷新,下拉加载 布局: <?xml version="1.0" encoding="utf-8"?> ...

  2. iscroll.js实现上拉刷新,下拉加载更多,应用技巧项目实战

    上拉刷新,下拉加载更多...仿原生的效果----iscroll是一款做滚动效果的插件,具体介绍我就不废话,看官方文档,我只写下我项目开发的一些用到的用法: (如果不好使,调试你的css,想必是个很蛋疼 ...

  3. vux (scroller)上拉刷新、下拉加载更多

    1)比较关键的地方是要在 scroller 组件上里加一个 ref 属性 <scroller :lockX=true height="-170" :pulldown-conf ...

  4. iOS--MJRefresh的使用 上拉刷新和下拉加载

    1.一般使用MJRefresh 来实现上拉刷新和下拉加载功能 2.MJRefresh 下载地址:https://github.com/CoderMJLee/MJRefresh 3. MJRefresh ...

  5. 【转】vux (scroller)上拉刷新、下拉加载更多

    1)比较关键的地方是要在 scroller 组件上里加一个 ref 属性 <scroller :lockX="true" height="-170" :p ...

  6. Android PullToRefreshListView上拉刷新和下拉刷新

    PullToRefreshListView实现上拉和下拉刷新有两个步骤: 1.设置刷新方式 pullToRefreshView.setMode(PullToRefreshBase.Mode.BOTH) ...

  7. ListView(2)最简单的上拉刷新,下拉刷新

    最简单的上拉刷新和下拉刷新,当listview滚动到底部时向上拉刷新数据.当listview滚动到最顶部时下拉刷新.       图1,上拉刷新 图2,下拉刷新 1,设置lisview,加载heade ...

  8. android ListView的上部下拉刷新下部点击加载更多具体实现及拓展

    android ListView的上部下拉刷新下部点击加载更多具体实现及拓展 ListView下拉刷新,上拉自动加载更多 下拉刷新以及加载更多

  9. ListView(2)最简单的上拉刷新、下拉刷新代码

    效果 最简单的上拉刷新和下拉刷新,当listview滚动到底部时向上拉刷新数据.当listview滚动到最顶部时下拉刷新.       图1,上拉刷新 图2,下拉刷新 1.设置lisview 加载he ...

随机推荐

  1. Ruby--Array

    --后面连接其它数组:[ARRAY].concat([OTHER ARRAY]) --排序:sort,进阶:sort_by{|obj| obj.[VALUE]} --随机获取:[ARRAY].samp ...

  2. 【转】UML图中类之间的关系

    原文:http://blog.csdn.net/hguisu/article/details/7609483   类与类图 1) 类(Class)封装了数据和行为,是面向对象的重要组成部分,它是具有相 ...

  3. ::after,::before使用

    ::after,::before使用   1.:before 选择器在被选元素的内容前面插入内容. 请使用 content 属性来指定要插入的内容. <!DOCTYPE html> < ...

  4. linux实现c多进程

    线程(thread)技术早在60年代就被提出,但真正应用多线程到操作系统中去,是在80年代中期,solaris是这方面的佼佼者.传统的Unix也支持线程的概念,但是在一个进程(process)中只允许 ...

  5. CLH锁 、MCS锁

    一.引文 1.1 SMP(Symmetric Multi-Processor) 对称多处理器结构,指服务器中多个CPU对称工作,每个CPU访问内存地址所需时间相同.其主要特征是共享,包含对CPU,内存 ...

  6. delphi android 录像(调用Java的功能)

    delphi xe系列自带的控件都无法保存录像,经网友帮忙,昨天终于实现了录像功能(但有个问题是录像时无画面显示),程序主要使用了JMediaRecorder,MediaRecorder的使用方法可参 ...

  7. GIT 在本地保存账户和密码

    原文链接:http://www.jianshu.com/p/908591004f3b 解决方法,在本地的工程文件夹的.git下打开config文件 添加: [credential] helper = ...

  8. android动态调试samli代码(转)

    转载自看雪http://bbs.pediy.com/showthread.php?t=189610,非常感谢原作者分享! 跟踪apk一般的做法是在反编译的smali代码中插入log输出,然后重新编译运 ...

  9. Ajax无刷新提交

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. Fatal error: Cannot redeclare tran() (previously declared in

    解决方法如下: 1.你该段源码里面是不是有include 或者require 之类的包含其他文件函数 包含的文件里已经有 函数 nw() 的定义 而这段代码里又有nv()的定义 所以出现redecla ...