Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma mark - Table View Methods
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 10;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- //Create cell and set delegate
- MCSwipeTableViewCell *cell = [[MCSwipeTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
- cell.delegate = self;
- cell.cellIdNumber = [NSNumber numberWithInteger:indexPath.row];
- //Remove inset of iOS 7 separators.
- if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
- cell.separatorInset = UIEdgeInsetsZero;
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleGray];
- //Setting the background color of the cell.
- cell.contentView.backgroundColor = [UIColor colorWithRed:0.161 green:0.255 blue:0.506 alpha:1];
- //Set different color for swiped / completed cells
- if ([self.checklistManager.swipedCellIdNumbers containsObject:cell.cellIdNumber]) {
- cell.contentView.backgroundColor = [UIColor colorWithRed:1.000 green:0.310 blue:0.000 alpha:1];
- cell.backgroundColor = [UIColor colorWithRed:1.000 green:0.310 blue:0.000 alpha:1];
- }
- // Configuring the views and colors.
- UIView *checkView = [self viewWithImageName:@"check"];
- UIColor *greenColor = [UIColor colorWithRed:85.0 / 255.0 green:213.0 / 255.0 blue:80.0 / 255.0 alpha:1.0];
- //Setting the default inactive state color to the tableView background color.
- [cell setDefaultColor:[UIColor grayColor]];
- //Set the cell text based on the index path's row property
- switch (indexPath.row) {
- case 0:
- cell.textLabel.text = @"Square roots";
- break;
- case 1:
- cell.textLabel.text = @"Cube roots";
- break;
- case 2:
- cell.textLabel.text = @"Ratios and Proportions";
- break;
- case 3:
- cell.textLabel.text = @"Percents";
- break;
- case 4:
- cell.textLabel.text = @"Measurements";
- break;
- case 5:
- cell.textLabel.text = @"Geometry";
- break;
- case 6:
- cell.textLabel.text = @"Coordinate graphs";
- break;
- case 7:
- cell.textLabel.text = @"Linear functions";
- break;
- case 8:
- cell.textLabel.text = @"Scientific notation";
- break;
- case 9:
- cell.textLabel.text = @"Absolute value";
- break;
- case 10:
- cell.textLabel.text = @"Radical expressions";
- break;
- default:
- break;
- }
- //cell.textLabel.text = @"This is a checklist item.";
- cell.textLabel.font = [UIFont fontWithName:@"Avenir" size:17.0f];
- cell.textLabel.textColor = [UIColor whiteColor];
- //Adding gestures per state basis.
- [cell setSwipeGestureWithView:checkView color:greenColor mode:MCSwipeTableViewCellModeExit state:MCSwipeTableViewCellState1 completionBlock:^(MCSwipeTableViewCell *cell, MCSwipeTableViewCellState state, MCSwipeTableViewCellMode mode) {
- NSLog(@"Did swipe \"Checkmark\" cell");
- //Add swiped row to swiped rows array
- [self.checklistManager.swipedCellIdNumbers addObject:cell.cellIdNumber];
- [self.tableView reloadData];
- }];
- return cell;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement