I have a table view and I’m toggling its dataDource with two UIButtons (like tabs).
- (IBAction)dataToggler:(id)sender {
int buttonTag = ((UIButton*)sender).tag;
if(_firstTab.selected && buttonTag != 1){
AppDelegate *myAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
myAppDelegate.isFeatured = TRUE;
[myAppDelegate loadEvents];
numberOfSections = 1;
_firstTab.selected = NO;
_secondTab.selected = YES;
} else if(_secondTab.selected && buttonTag != 2){
AppDelegate *myAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
myAppDelegate.isFeatured = FALSE;
[myAppDelegate loadEvents];
numberOfSections = 2;
_firstTab.selected = YES;
_secondTab.selected = NO;
}
[tableView reloadData];
}
Each time when I click on one of the buttons my xml its parsed and added into separate arrays; the arrays contains a list of events (eg. first section with now events and the 2nd one with the rest of them).
The problem which I have is when I have the 2nd button selected I have two section but sometimes my first section is empty so I don’t want to display that section if its empty; please take a quick look to my code files…
Right now if my second tab (button) is selected I’m getting an empty table…
My code files are: myViewController and myAppDelegate
In your tableView datasource, implement this method: