I added a button on the uinavigationbar I want to use it to delete all the rows of uitablview
How can I do that?
[self.tableView reloadData]
is not working here
I added a button on the uinavigationbar I want to use it to delete all the rows of uitablview
How can I do that?
[self.tableView reloadData]
is not working here
On the button action event remove all the objects from itemArray then reload tableView data. Before this make sure that in tableView delegate numberOfRowInsection you are passing itemArray count like that:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [itemArray count];
}
// button action//
-(IBAction)deleteTableViewData
{
[itemArray removeAllObjects];
[tableView reloadData];
}
First remove all objects from the datasource:
[dataArray removeAllObjects]
and then reload the UITableView
[self.tableView reloadData]
You are using an array to populate the UITableView. Remove all the objects from there and reload your data.
Make sure your numberOfRowsInSection is returning the array count and not a static value. And then do this:
[dataSourceArray removeAllObjects];
[tableView reloadData];