#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. CSS兼容性

    1,浮动 ie6中,设置浮动的元素,width自动包裹内容了.通常我们要设定一下这个元素的宽度 子元素浮动父容器高度不能自适应的CSS解决方法 网页前端工作者经常会遇到子元素设置float浮动后导致父 ...

  2. Javascript 笔记与总结(2-2)Javascript 变量

    js 的变量名可以由 _,数字,字母,$ 组成,且 不能以数字开头.在 jQuery 中就定义了一个全局变量 $ . 声明变量用 var 变量名,如果不用 var,则会污染全局. js 变量类型包括: ...

  3. php实现上传图片保存到数据库的方法

    http://www.jb51.net/article/61034.htm 作者:傲雪星枫 字体:[增加 减小] 类型:转载   这篇文章主要介绍了php实现上传图片保存到数据库的方法,可通过将图片保 ...

  4. oracle sqlplus常用命令

    登录到sqlplus sqlplus user/pwd@dbname 不登录使用 sqlplus /nolog 查看当前登录用户 show user; 更改用户密码 ALTER USER USER I ...

  5. 微信公众账号开发教程(三) 实例入门:机器人(附源码) ——转自http://www.cnblogs.com/yank/p/3409308.html

    一.功能介绍 通过微信公众平台实现在线客服机器人功能.主要的功能包括:简单对话.查询天气等服务. 这里只是提供比较简单的功能,重在通过此实例来说明公众平台的具体研发过程.只是一个简单DEMO,如果需要 ...

  6. android studio 编程中用到的快捷键

    1.Ctrl+Alt+T可以把代码包在一块内,例如try/catch Version:0.9 StartHTML:-1 EndHTML:-1 StartFragment:0000000111 EndF ...

  7. C#Form窗体通过代码改变尺寸

    通过Size属性不能得到正确的窗体尺寸, 怎么办? 还需要设置 MaximumSize 属性和你的 size属性尺寸一样. this.FormBorderStyle = FormBorderStyle ...

  8. C++ 安全字符串拼接

    #include <stdio.h> #include <stdint.h> #include <stdarg.h> #if defined(__GNUC__) # ...

  9. ECSHOP给分类添加图

    1.修改/admin/template/category_info.html <tr> <td>{$lang.cat_img}:</td> <td> & ...

  10. LightOj1383 - Underwater Snipers(贪心 + 二分)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1383 题意:在平面图中,有一条河,用直线y=k表示,河上面(y>k)的都是敌方区 ...