I have implemented a similar one by using tableview header.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 32)];
UIButton *sectionButton = [UIButton buttonWithType:UIButtonTypeCustom];
sectionButton.tag = section;
sectionButton.frame = customView.frame;
[sectionButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
UILabel *titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 32)] autorelease];
titleLabel.textAlignment = UITextAlignmentCenter;
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = [UIFont boldSystemFontOfSize:13];
titleLabel.textColor = [UIColor whiteColor];
NSString *tableHeader = @"table_header_down.png";
switch (section) {
case 0:
titleLabel.text = @"Section1";
tableHeader = showSection1 ? @"table_header_up.png" : @"table_header_down.png";
break;
case 1:
titleLabel.text = @"Section2";
tableHeader = showSection2 ? @"table_header_up.png" : @"table_header_down.png";
break;
case 2:
titleLabel.text = @"Section3";
tableHeader = showSection3 ? @"table_header_up.png" : @"table_header_down.png";
break;
case 3:
titleLabel.text = @"Section4";
tableHeader = showSection4 ? @"table_header_up.png" : @"table_header_down.png";
break;
default:
break;
}
[sectionButton setImage:[UIImage imageNamed:tableHeader] forState:UIControlStateNormal];
[customView addSubview:sectionButton];
[customView addSubview:titleLabel];
return [customView autorelease];
}
Then I loaded the cell accordingly to the boolean values corresponding to each section, number of rows returns 0 if Bool 0, and returns the count when Bool 1.