UITableView insert rows without scrolling

前端 未结 6 1380
我在风中等你
我在风中等你 2020-12-05 03:13

I have a list of data that I\'m pulling from a web service. I refresh the data and I want to insert the data in the table view above the current data, but I want to keep my

6条回答
  •  失恋的感觉
    2020-12-05 03:42

    The best way I found to get my desired behavior is to not animate the insertion at all. The animations were causing the choppyness.

    Instead I am calling:

    [tableView reloadData];
    
    // set the content offset to the height of inserted rows 
    // (2 rows * 44 points = 88 in this example)
    [tableView setContentOffset:CGPointMake(0, 88)]; 
    

    This makes the reload appear at the same time as the content offset change.

提交回复
热议问题