Have a reloadData for a UITableView animate when changing

前端 未结 17 2950
感动是毒
感动是毒 2020-11-28 17:25

I have a UITableView that has two modes. When we switch between the modes I have a different number of sections and cells per section. Ideally, it would do some cool anima

17条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 18:08

    I believe you can just update your data structure, then:

    [tableView beginUpdates];
    [tableView deleteSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:YES];
    [tableView insertSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:YES];
    [tableView endUpdates];
    

    Also, the "withRowAnimation" is not exactly a boolean, but an animation style:

    UITableViewRowAnimationFade,
    UITableViewRowAnimationRight,
    UITableViewRowAnimationLeft,
    UITableViewRowAnimationTop,
    UITableViewRowAnimationBottom,
    UITableViewRowAnimationNone,
    UITableViewRowAnimationMiddle
    

提交回复
热议问题