Call function only after reloadData has finished

前端 未结 3 1197
挽巷
挽巷 2021-01-07 13:56

I have a tableView and need to perform a function once the tableView has been reloaded. How do I know if reloadData has finished? Lets

3条回答
  •  广开言路
    2021-01-07 15:01

    You can add a method/category on UITableView or even subclass UITableView:

    -(void)reloadDataAndWait:(void(^)(void))waitBlock {
        [self reloadData];//if subclassed then super. else use [self.tableView
        if(waitBlock){
            waitBlock();
        }
    }
    

    And you need to use it as

    [self.tableView reloadDataAndWait:^{
        //call the required method here                                            
    }];
    

提交回复
热议问题