reload uitableview with new data caused flickering

后端 未结 9 1054
Happy的楠姐
Happy的楠姐 2020-12-16 11:55

I added an infinite scrolling feature and realized that whenever I reload the uitableview, the view flickers..I am not sure how to fix the flickering at this point. Please h

相关标签:
9条回答
  • 2020-12-16 12:42

    y you are using deleteRowsAtIndex? If you reload table all table delegate methods are called. I think it is taking time to delete all rows and then again reload. Just use reload method and try.

    0 讨论(0)
  • 2020-12-16 12:44

    Below code worked for me like a charm!

    Objective-C

    [UIView performWithoutAnimation:^{
       [self.tableview reloadData];
       [self.tableview beginUpdates];
       [self.tableview endUpdates];
    }];
    

    Swift 4

    UIView.performWithoutAnimation {
        self.tableView.reloadData()
        self.tableView.beginUpdates()
        self.tableView.endUpdates()
    }
    
    0 讨论(0)
  • 2020-12-16 12:44

    Just in case all other answers do not solve your problem, I post my solution.

    If you use estimated height estimatedSectionHeaderHeight or estimatedRowHeight or -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath, and with dynamic row count for each section (e.g. expandable two level tableView)

    you should stop using this and implement -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath to return the correct height.

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