UIView and UITableView, reloadData weird latency

后端 未结 2 2125
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 18:22

I have something weird with the repaint of my view controller. The view controller contains an UITableView and a spinner.

I have an updateFeed function

相关标签:
2条回答
  • 2021-02-08 18:59

    Here is my new answer for your editted question.

    I don't know exactly what happens because usually, the table view will reload data and redraw the table view in separate thread that will not run that slow. Here is some guess that you can check:

    1/ Check if you reuse the cell by cell identifier correctly

    2/ Check if any other data source and delegate methods do heavy, networking job like in

    * – tableView:cellForRowAtIndexPath:  required method
    * – numberOfSectionsInTableView:
    * – tableView:numberOfRowsInSection:  required method
    

    or in:

    #  – tableView:heightForRowAtIndexPath:
    # – tableView:indentationLevelForRowAtIndexPath:
    # – tableView:willDisplayCell:forRowAtIndexPath:
    
    0 讨论(0)
  • 2021-02-08 19:01

    I'm not sure what's causing your delay, but it smells like it could be a threading issue. Many UIKit classes aren't thread safe. As a general rule, you should try to make sure that all of your UI interaction happens on the main thread. In the code you originally posted, it looked like you were calling reloadData from your background thread, which seems risky. It's not clear to me which thread it's being called from now that you've changed your code.

    Go through your doUpdate code path and make sure that any calls back to your delegate that could lead to a UI update are being done via performSelectorOnMainThread:.

    0 讨论(0)
提交回复
热议问题