#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

最新文章

  1. SQLSERVER中如何快速比较两张表的不一样
  2. no leveldbjni64-1.8 in java.library.path
  3. SDIO接口
  4. 原 Linux搭建SVN 服务器
  5. 简单模拟java动态动态代理机制的底层实现原理
  6. Windows配置Python编程环境
  7. C#连接oracle数据库提示ORA-12154: TNS: 无法解析指定的连接标识符
  8. 用人类社会工程学对C语言中的一些基本概念的剖析与理解
  9. No space left on device Linux系统磁盘空间已满
  10. 使用Jenkins遇到的问题
  11. LeetCode(100):相同的树
  12. CentOS YUM 安装 TOMCAT6
  13. excel的小bug
  14. css实现常用的两栏三栏布局
  15. JDK和Eclipse的下载路径
  16. JavaScript的replace方法与正则表达式结合应用讲解
  17. 散列表碰撞处理、开链法、HashTable散列
  18. [NOI2018]归程 kruskal重构树
  19. 更改idea快捷键方式为eclipse风格
  20. HBase中的TTL与MinVersion的关系

热门文章

  1. 《Java核心技术卷二》笔记(二)文件操作和内存映射文件
  2. mongodb 3.0 版本分片部署步骤
  3. NV Maxwell architecture
  4. 省略nslog打印
  5. li标签之间的空隙问题(转)
  6. Unknown collation: &#39;utf8mb4_unicode_ci&#39;
  7. 20145317彭垚《Java程序设计》第3周学习总结
  8. smarty3.0中文手册文档API及使用指南
  9. faker image
  10. arch框架人员、组织说明