uitableview没有滚动到底部

时间:2014-12-05 11:28:42

标签: ios xcode uitableview scroll

我有一个UITableView,我动态添加行。基本上是一个聊天应用程序。

我需要在reloadData

之后将UITableView滚动到底部

我的代码是:

滚动到这里: https://dl-web.dropbox.com/get/Screen%20Shot%202014-12-05%20at%2013.04.23.png?_subject_uid=44249794&w=AADgJkJJOGK_ANH_cXWnxeXmhFmF5KHjZllg-kP66HARdw

手动滚动时,我可以进一步滚动到此处:https://dl-web.dropbox.com/get/Screen%20Shot%202014-12-05%20at%2013.05.19.png?_subject_uid=44249794&w=AADtQEfMHMy0Ounri5W3gBTLNgR4uckT_gBdYQel9vD1qQ

我的代码:

 [_chatTable reloadData];
 NSIndexPath* indexPath = [NSIndexPath indexPathForRow: [[AppData getChatLog]count]-1 inSection: 0];
 [_chatTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];

我需要UITableView一直滚动到底部。

1 个答案:

答案 0 :(得分:0)

抱歉,我无法打开指定的链接。试试这个

UITableView *yourTableView = yourTableViewToBeSetHere;

CGRect lastCellRect = CGRectMake(0, CGFLOAT_MAX, 50, 50);

// Scroll to the particular rect
[yourTableView scrollRectToVisible:lastCellRect
                          animated:YES];
祝你好运!

相关问题