UITableView,滚动到底部重新加载? [英] UITableView , Scroll to bottom on reload?

查看:252
本文介绍了UITableView,滚动到底部重新加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView与动态更新的单元格。一切工作正常,除了当reload被调用(见下文)刷新cels在表中我希望表滚动到底部显示新的条目。

   - (void)reloadTable:(NSNotification *)notification {
NSLog(@RELOAD TABLE ... );
[customTableView reloadData];
//滚动到UITable的底部....
}

我计划使用scrollToRowAtIndexPath:atScrollPosition:animated:但是,然后注意到,我没有访问indexPath。

解决方案

使用:

  NSIndexPath * ipath = [NSIndexPath indexPathForRow:cells_count-1 inSection:sections_count-1]; 
[tableView scrollToRowAtIndexPath:ipath atScrollPosition:UITableViewScrollPositionTop animated:YES];

也可以手动指定段索引(如果一个段=> index = 0) p>

I have a UITableView with cells that are dynamically updated. Everything works fine apart from when reload is called (see below) to refresh the cels in the table I would like the table to scroll to the bottom to show the new entries.

- (void)reloadTable:(NSNotification *)notification {
    NSLog(@"RELOAD TABLE ...");
    [customTableView reloadData];
    // Scroll to bottom of UITable here ....
}

I was planning to use scrollToRowAtIndexPath:atScrollPosition:animated: but then noticed that I don't have access to an indexPath. Does anyone know how to do this, or of a delegate callback that I could use?

解决方案

Use:

NSIndexPath* ipath = [NSIndexPath indexPathForRow: cells_count-1 inSection: sections_count-1];
[tableView scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionTop animated: YES];

Or you can specify the section index manually (If one section => index=0).

这篇关于UITableView,滚动到底部重新加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆