As explained in this answer , reloading the UITableView occurs the next time the layout starts (usually when you return control to the launch loop).
So, you can schedule your code after the next layout using the main send queue. In your case:
func getAllTimeEvent() { self.arrAllTimeEvent = ModelManager.getInstance().getAllTimeEvent(from: self.apportmentDateFrom, to: self.apportmentDateTo) self.tblTimeEvent.reloadData() DispatchQueue.main.async { self.tblTimeEvent.scrollToRow(at: self.boldRowPath ?? [0,0], at: .top, animated: true) } }
You can also force the layout by manually calling layoutIfNeeded . But this is usually not a good idea (the previous option is the best):
func getAllTimeEvent() { self.arrAllTimeEvent = ModelManager.getInstance().getAllTimeEvent(from: self.apportmentDateFrom, to: self.apportmentDateTo) self.tblTimeEvent.reloadData() self.tblTimeEvent.layoutIfNeeded() self.tblTimeEvent.scrollToRow(at: self.boldRowPath ?? [0,0], at: .top, animated: true) }
source share