I need to literally redraw a UITableView upon an event in my code. But everything I’ve tryed doesn’t seem to work. I’ve tried [self.tableView reloadData], I’ve played with the delegates. The goal I’m trying to achieve is to render a completely different UITableView, with differently formatted cells. So I need to redraw the table. Any help would be appreciated.
Heres my code:
...
if/else...
}
//Now I want to reload the tableView
[tableView reloadData]; //Isn't getting it done
NSLog(@"index = %i", index); //Always fires
tableView.delegate = self; // Didn't help
[tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; // Also nothing
}
The point of what I’m trying to do is this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
if (segmentOptions == snacks) {
cell = [[TableViewCell1 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
NSLog(@"A");
} else {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
NSLog(@"B");
}
}
...
}
You possibly meant something like