reloadRowsAtIndexPaths:withRowAnimation: crashes my app

后端 未结 8 1979
谎友^
谎友^ 2021-02-07 01:33

I got a strange problem with my UITableView: I use reloadRowsAtIndexPaths:withRowAnimation: to reload some specific rows, but the app crashes with an seemingly unre

8条回答
  •  野性不改
    2021-02-07 01:48

    After many try, I found "reloadRowsAtIndexPaths" can be only used in certain places if only change the cell content not insert or delete cells. Not any place can use it, even you wrap it in

    [self beginUpdates];
    //reloadRowsAtIndexPaths
    [self endUpdates];
    

    The places I found that can use it are:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (IBAction) unwindToMealList: (UIStoryboardSegue *) sender

    Any try from other places like call it from "viewDidLoad" or "viewDidAppear", either will not take effect (For the cell already loaded I mean, reload will not take effect) or cause exception.

    So try to use "reloadRowsAtIndexPaths" only in those places.

提交回复
热议问题