加载完成后,如何一直滚动到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)
})
}
}
答案 0 :(得分:0)
if (tableView.contentSize.height > tableView.frame.size.height)
{
tableView.setContentOffset(CGPointMake(0, tableView.contentSize.height - tableView.frame.size.height), animated: true)
}