iphone - UITableView ,重新加载时滚动到底部?

标签 iphone objective-c cocoa-touch

我有一个 UITableView 和动态更新的 cells。除了调用 tableview.reload (见下文)刷新表格中的 cells 之外,一切正常 我希望表格滚动到底部以显示新的条目。

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

我本来打算使用 scrollToRowAtIndexPath:atScrollPosition:animated: 但后来发现我无法访问 indexPath

有谁知道如何做到这一点,或者我可以使用的 delegate 回调?

最佳答案

用途:

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

或者您可以手动指定节索引(如果一个节=>索引=0)。

关于iphone - UITableView ,重新加载时滚动到底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5112346/

相关文章:

iphone - 如何在 iOS 设备上创建 PBKDF2 key

ios - 具有大量 UIButton 的 UIScrollView

iphone - 将 Twilo sdk 集成到 iOS 时出现异常

iphone - OpenGL ES [CAEAGLLayer] 内容的高分辨率视网膜显示屏幕截图

iphone - iPhone 5启动图片和App评论

ios - 电子表格样式控件 (iOS)?

ios - 创建 UIViewController 的多个实例

iOS 多对等连接显示相同的设备名称两次

iphone - 使用drawRect :?进行自定义渲染时我是否负责裁剪

ios - 无法将应用程序设置为仅限 iPhone