Advertisement
nsocean

EESecondTableViewController table view methods

Sep 4th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma mark - Table View Methods
  2. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  3. {
  4.     return 1;
  5. }
  6.  
  7. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  8. {
  9.     return 10;
  10. }
  11.  
  12. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  13. {
  14.     //Create cell and set delegate
  15.     MCSwipeTableViewCell *cell = [[MCSwipeTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
  16.    
  17.     cell.delegate = self;
  18.     cell.cellIdNumber = [NSNumber numberWithInteger:indexPath.row];
  19.    
  20.         //Remove inset of iOS 7 separators.
  21.         if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  22.             cell.separatorInset = UIEdgeInsetsZero;
  23.         }
  24.        
  25.         [cell setSelectionStyle:UITableViewCellSelectionStyleGray];
  26.        
  27.         //Setting the background color of the cell.
  28.         cell.contentView.backgroundColor = [UIColor colorWithRed:0.161 green:0.255 blue:0.506 alpha:1];
  29.    
  30.    
  31.     //Set different color for swiped / completed cells
  32.     if ([self.checklistManager.swipedCellIdNumbers containsObject:cell.cellIdNumber]) {
  33.                
  34.         cell.contentView.backgroundColor = [UIColor colorWithRed:1.000 green:0.310 blue:0.000 alpha:1];
  35.         cell.backgroundColor = [UIColor colorWithRed:1.000 green:0.310 blue:0.000 alpha:1];
  36.     }
  37.  
  38.     // Configuring the views and colors.
  39.     UIView *checkView = [self viewWithImageName:@"check"];
  40.     UIColor *greenColor = [UIColor colorWithRed:85.0 / 255.0 green:213.0 / 255.0 blue:80.0 / 255.0 alpha:1.0];
  41.    
  42.    
  43.     //Setting the default inactive state color to the tableView background color.
  44.     [cell setDefaultColor:[UIColor grayColor]];
  45.    
  46.     //Set the cell text based on the index path's row property
  47.    
  48.     switch (indexPath.row) {
  49.         case 0:
  50.             cell.textLabel.text = @"Square roots";
  51.             break;
  52.         case 1:
  53.             cell.textLabel.text = @"Cube roots";
  54.             break;
  55.         case 2:
  56.             cell.textLabel.text = @"Ratios and Proportions";
  57.             break;
  58.         case 3:
  59.             cell.textLabel.text = @"Percents";
  60.             break;
  61.         case 4:
  62.             cell.textLabel.text = @"Measurements";
  63.             break;
  64.         case 5:
  65.             cell.textLabel.text = @"Geometry";
  66.             break;
  67.         case 6:
  68.             cell.textLabel.text = @"Coordinate graphs";
  69.             break;
  70.         case 7:
  71.             cell.textLabel.text = @"Linear functions";
  72.             break;
  73.         case 8:
  74.             cell.textLabel.text = @"Scientific notation";
  75.             break;
  76.         case 9:
  77.             cell.textLabel.text = @"Absolute value";
  78.             break;
  79.         case 10:
  80.             cell.textLabel.text = @"Radical expressions";
  81.             break;
  82.            
  83.         default:
  84.             break;
  85.     }
  86.     //cell.textLabel.text = @"This is a checklist item.";
  87.     cell.textLabel.font = [UIFont fontWithName:@"Avenir" size:17.0f];
  88.     cell.textLabel.textColor = [UIColor whiteColor];
  89.    
  90.     //Adding gestures per state basis.
  91.     [cell setSwipeGestureWithView:checkView color:greenColor mode:MCSwipeTableViewCellModeExit state:MCSwipeTableViewCellState1 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) {
  92.         NSLog(@"Did swipe \"Checkmark\" cell");
  93.        
  94.      
  95.         //Add swiped row to swiped rows array
  96.         [self.checklistManager.swipedCellIdNumbers addObject:cell.cellIdNumber];
  97.        
  98.         [self.tableView reloadData];
  99.     }];
  100.    
  101.     return cell;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement