- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *normalCellIdentifier = @"NormalCell";
static NSString *headerCellIdentifier = @"HeaderCell";
static NSString *statisticCellIdentifier = @"StatisticCell";
if ([self tableView:tableView canCollapseSection:indexPath.section]) {
if (!indexPath.row) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:headerCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:headerCellIdentifier];
}
//first row
cell.textLabel.text = @"Expandable"; //only top row showing
if ([expandedSections containsIndex:indexPath.section]) {
cell.accessoryView = [QACustomColoredAccessory accessoryWithColor:[UIColor grayColor] type:QACustomColoredAccessoryTypeUp];
}
else {
cell.accessoryView = [QACustomColoredAccessory accessoryWithColor:[UIColor grayColor] type:QACustomColoredAccessoryTypeDown];
}
return cell;
}
else {
//all other rows
/*
cell.textLabel.text = @"Some Detail";
cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
*/
//This is the custom cell. I have a separate class derived from UITableViewCell class for that.
DashboardCell *cell = [tableView dequeueReusableCellWithIdentifier:statisticCellIdentifier];
if (cell == nil) {
cell = [[DashboardCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:statisticCellIdentifier];
}
cell.numberOfMails.text = @"18";
cell.mailType.text = @"New Mail";
[cell.numberOfOverdueMails setBackgroundColor:[UIColor colorWithRed:244/255.0f green:119/255.0f blue:125/255.0f alpha:1.0f]];
cell.numberOfOverdueMails.titleLabel.text = @"200";
return cell;
}
}
else {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:normalCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:normalCellIdentifier];
}
cell.accessoryView = nil;
cell.textLabel.text = @"Normal cell";
return cell;
}
return nil;
}