2016-08-15 90 views
0

如何在完成加載時一直滾動到UITableView的底部?滾動到UITableView的底部(UITableView在UITableViewCell中)

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

' tableView.setContentOffset(CGPointMake(0,tableView.contentSize.height - tableView.frame.size.height),animated:true)' – washloops

+0

如果我補充說,它不會一直滾動到底部和我的PullToRefresh函數在加載時被調用。 –

回答

0

你可以像這樣:

if (tableView.contentSize.height > tableView.frame.size.height) 
{ 
    tableView.setContentOffset(CGPointMake(0, tableView.contentSize.height - tableView.frame.size.height), animated: true) 
} 
相關問題