how to clear all the rows of uitableview

前端 未结 8 551
半阙折子戏
半阙折子戏 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-03 00:02
    tableView.dataSource = nil
    tableView.reloadData()
    
    0 讨论(0)
  • 2021-01-03 00:03

    There should be a UITableView delegate method that populates the UITableView control:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    

    Find this method and change where the data for each cell is being pulled from. If you are currently using the indexPath to access an array of values to populate your tableView cells, you can programmatically switch to an array of empty values, or even just return empty cells from this method when the condition is right.

    0 讨论(0)
提交回复
热议问题