Advertisement
Guest User

cocoanetics question

a guest
Mar 6th, 2013
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3.     static NSString *normalCellIdentifier = @"NormalCell";
  4.     static NSString *headerCellIdentifier = @"HeaderCell";
  5.     static NSString *statisticCellIdentifier = @"StatisticCell";
  6.    
  7.     if ([self tableView:tableView canCollapseSection:indexPath.section]) {
  8.        
  9.         if (!indexPath.row) {
  10.            
  11.             UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:headerCellIdentifier];
  12.             if (cell == nil) {
  13.                 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:headerCellIdentifier];
  14.             }
  15.            
  16.             //first row
  17.             cell.textLabel.text = @"Expandable";  //only top row showing
  18.            
  19.             if ([expandedSections containsIndex:indexPath.section]) {
  20.                 cell.accessoryView = [QACustomColoredAccessory accessoryWithColor:[UIColor grayColor] type:QACustomColoredAccessoryTypeUp];
  21.             }
  22.             else {
  23.                 cell.accessoryView = [QACustomColoredAccessory accessoryWithColor:[UIColor grayColor] type:QACustomColoredAccessoryTypeDown];
  24.             }
  25.            
  26.             return cell;
  27.         }
  28.         else {
  29.             //all other rows
  30.             /*
  31.             cell.textLabel.text = @"Some Detail";
  32.             cell.accessoryView = nil;
  33.             cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  34.             */
  35.            
  36.             //This is the custom cell. I have a separate class derived from UITableViewCell class for that.
  37.             DashboardCell *cell = [tableView dequeueReusableCellWithIdentifier:statisticCellIdentifier];
  38.             if (cell == nil) {
  39.                 cell = [[DashboardCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:statisticCellIdentifier];
  40.             }
  41.            
  42.             cell.numberOfMails.text = @"18";
  43.             cell.mailType.text = @"New Mail";
  44.        
  45.             [cell.numberOfOverdueMails setBackgroundColor:[UIColor colorWithRed:244/255.0f green:119/255.0f blue:125/255.0f alpha:1.0f]];
  46.             cell.numberOfOverdueMails.titleLabel.text = @"200";
  47.            
  48.             return cell;
  49.         }
  50.     }
  51.     else {
  52.         UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:normalCellIdentifier];
  53.         if (cell == nil) {
  54.             cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:normalCellIdentifier];
  55.         }
  56.        
  57.         cell.accessoryView = nil;
  58.         cell.textLabel.text = @"Normal cell";
  59.        
  60.         return cell;
  61.     }
  62.    
  63.     return nil;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement