how to clear all the rows of uitableview

前端 未结 8 685
半阙折子戏
半阙折子戏 2021-01-02 23:32

I added a button on the uinavigationbar I want to use it to clear all the rows of uitablview

How can I do that?

8条回答
  •  轮回少年
    2021-01-02 23:42

    A bit late... but try this:

    Where you want to clear the table:

    // clear table
    clearTable = YES;
    [table reloadData];
    clearTable = NO;
    

    This function should look like:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
        if(clearTable)
            return 0;
    
        (...)
    }
    

提交回复
热议问题