加载完成后,如何滚动到 UITableView 的底部?
UITableView 位于 UITableViewCell 中,UITableViewCell 位于 UItableView 本身中。
所以: UITableView --> UITableViewCell --> UITableView(滚动到此处底部)
这会崩溃:
func reloadData(){
if (neighbourhoodJoined){
messageInputView.hidden = false
chatroomMessagesListReversed = chatroomMessagesList.reverse() as! [ChatroomMessage]
chatroomTableView.reloadData()
dispatch_async(dispatch_get_main_queue(), { () -> Void in
var iPath = NSIndexPath(forRow: self.chatroomTableView.numberOfRowsInSection(0)-1,
inSection: self.chatroomTableView.numberOfSections-1)
self.chatroomTableView.scrollToRowAtIndexPath(iPath,
atScrollPosition: UITableViewScrollPosition.Bottom,
animated: true)
})
}
}
最佳答案
你可以喜欢这样:
if (tableView.contentSize.height > tableView.frame.size.height)
{
tableView.setContentOffset(CGPointMake(0, tableView.contentSize.height - tableView.frame.size.height), animated: true)
}
关于ios - 滚动到 UITableView 的底部(UITableView 在 UITableViewCell 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38949246/