繁体   English   中英

滚动到UITableView的底部(UITableView在UITableViewCell中)

[英]Scrolling to bottom of UITableView (UITableView is in a UITableViewCell)

加载完成后,如何一直滚动到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)
}

暂无
暂无

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

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