添加新单元格后,Swift UITableView不会以编程方式滚动到底部

添加新单元格后,Swift UITableView不会以编程方式滚动到底部,swift,uitableview,chat,ios9,xcode7,Swift,Uitableview,Chat,Ios9,Xcode7,我正在构建一个非常基本的聊天应用程序,用户可以在其中来回发送消息。当用户发送消息时,我当前将数据与parse同步,然后调用updateMessages func更新消息{ let messageQuery = Message.query() messageQuery.whereKey("contThread", equalTo: >selectedThread.objectId!) messageQuery.findObjectsInBackgroundWithBlock

我正在构建一个非常基本的聊天应用程序,用户可以在其中来回发送消息。当用户发送消息时,我当前将数据与parse同步,然后调用updateMessages

func更新消息{

   let messageQuery = Message.query()
   messageQuery.whereKey("contThread", equalTo: >selectedThread.objectId!)
   messageQuery.findObjectsInBackgroundWithBlock { (objects, error) ->> Void in
       if error == nil {
           if let objects = objects as? [Message] {
               print(objects.count)
               print("FLAG")
               messages = objects
               self.messageTable.reloadData()
               print(messages.count)
               self.scrollToBottom()
           }
       }
   }
}

函数,该函数从解析中提取更新的数据并重新填充messages表。我希望tableView在消息表重新填充后以编程方式滚动到底部,但无法理解为什么要调用scrollToBottom

卷轴底部功能{

   if messageTable.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0)) != nil {
       messageTable.scrollToRowAtIndexPath(NSIndexPath(forRow: messages.count-1 , inSection: 0), atScrollPosition: .Bottom, animated: >false)
   }
}


在我的updateMessages函数结束时不起作用。欢迎提出任何/所有建议!谢谢

您是否尝试更新到主队列?似乎您正在后台队列中执行scrollToBottom操作?