How to scroll to the exact end of the UITableView?

前端 未结 16 2522
天涯浪人
天涯浪人 2020-12-07 18:48

I have a UITableView that is populated with cells with dynamic height. I would like the table to scroll to the bottom when the view controller is pushed from vi

16条回答
  •  轮回少年
    2020-12-07 19:08

    Works in Swift 4+ :

       self.tableView.reloadData()
        let indexPath = NSIndexPath(row: self.yourDataArray.count-1, section: 0)
        self.tableView.scrollToRow(at: indexPath as IndexPath, at: .bottom, animated: true)
    

提交回复
热议问题