IOS tableView下拉刷新,上拉刷新(LOW)
2015-09-25 17:29
459 查看
1.故事板
换成tabaleview
self.names =
[NSMutableArray
array];
self.names = [NSMutableArray
arrayWithObjects:@"a",@"a",@"a",@"a",@"a",
@"a",@"a",nil];
UIRefreshControl *iv =[[UIRefreshControl
alloc]init];
[iv
addTarget:self
action:@selector(refreshAction)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = iv;
-(void)refreshAction{
NSLog(@"hehe");
[self.names
insertObject:@"X"
atIndex:0];
[NSTimer
scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(backAction)
userInfo:nil
repeats:NO];
}
-(void)backAction{
[self.tableView
reloadData];
[self.refreshControl
endRefreshing];
}
- (NSInteger)tableView:(UITableView
*)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return
self.names.count;
;
}
- (UITableViewCell*)tableView:(UITableView
*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell= [tableView
dequeueReusableCellWithIdentifier:@"Cell"
forIndexPath:indexPath];
cell.textLabel.text
= self.names[indexPath.row];
if (indexPath.row ==
self.names.count-1)
{
for (int i=0;
i<indexPath.row; i++) {
[self.names
addObject:[NSString
stringWithFormat:@"%d",i]];
}
[self.tableView
reloadData];
}
return cell;
}
换成tabaleview
self.names =
[NSMutableArray
array];
self.names = [NSMutableArray
arrayWithObjects:@"a",@"a",@"a",@"a",@"a",
@"a",@"a",nil];
UIRefreshControl *iv =[[UIRefreshControl
alloc]init];
[iv
addTarget:self
action:@selector(refreshAction)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = iv;
-(void)refreshAction{
NSLog(@"hehe");
[self.names
insertObject:@"X"
atIndex:0];
[NSTimer
scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(backAction)
userInfo:nil
repeats:NO];
}
-(void)backAction{
[self.tableView
reloadData];
[self.refreshControl
endRefreshing];
}
- (NSInteger)tableView:(UITableView
*)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return
self.names.count;
;
}
- (UITableViewCell*)tableView:(UITableView
*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell= [tableView
dequeueReusableCellWithIdentifier:@"Cell"
forIndexPath:indexPath];
cell.textLabel.text
= self.names[indexPath.row];
if (indexPath.row ==
self.names.count-1)
{
for (int i=0;
i<indexPath.row; i++) {
[self.names
addObject:[NSString
stringWithFormat:@"%d",i]];
}
[self.tableView
reloadData];
}
return cell;
}
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?
- Android、iOS和Windows Phone中的推送技术详解
- IOS 改变键盘颜色代码
- 举例详解iOS开发过程中的沙盒机制与文件
- Android和IOS的浏览器中检测是否安装某个客户端的方法
- javascript实现阻止iOS APP中的链接打开Safari浏览器
- IOS开发第三方语音-微信语音
- iOS开发之路--微博OAuth授权_取得用户授权的accessToken
- 基于UIControl控件实现ios点赞功能
- iOS开发中实现邮件和短信发送的简单示例