简体   繁体   中英

swift tableview.scrollToRow() freezes ui

I have a ViewController with a tableview inside.

I add some rows and call tableview.reloadData() .

I use the tableview.scrollToRow() call to scroll to bottom of tableview . and it takes quite long which freezes the UI.

Is there a way to do this in another thread or something? I even put it in DispatchQueue but still freezes the UI. It almost takes about 5 seconds to execute the scrollToRow() call.

 DispatchQueue.main.async {
  self.tableView.reloadData()
  let indexPath = IndexPath(row: count-1, section: 0)
  self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
 }

If anyone is interested I have found that this is not a problem on 11.4 iOS. Suggest update to latest IOS and try if you are having similar issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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