繁体   English   中英

uitableview不会滚动到底部

[英]uitableview doesn't scroll to bottom

我有一个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-05%20at%2013.05.19.png?_subject_uid=44249794&w=AADtQEfMHMy0Ounri5W3gBTLNgR4uckT_gBdYQel9vD1q

我的代码:

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

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

抱歉,我无法打开给定的链接。

UITableView *yourTableView = yourTableViewToBeSetHere;

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

// Scroll to the particular rect
[yourTableView scrollRectToVisible:lastCellRect
                          animated:YES];

祝好运!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM