Hey. Can someone help me understand how to automatically compose table cell elements when editing in iOS 6.0? I set AutoLayout FALSE for the UITableViewCell Autosizing parameter set in the upper right corner of the Attributes Inspector! Images on the right side of the image are overlapped by delete buttons. Please refer to the attached image. Below is the code for this. Anyway, can I fix this problem?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { PlayerCell *cell = (PlayerCell *)[tableView dequeueReusableCellWithIdentifier:@"PlayerCell"]; Player *player = [self.players objectAtIndex:indexPath.row]; cell.nameLabel.text = player.name; cell.gameLabel.text = player.game; cell.ratingImageView.image = [self imageForRating:player.rating]; return cell; } - (UIImage *)imageForRating:(int)rating { switch (rating) { case 1: return [UIImage imageNamed:@"1StarSmall.png"]; case 2: return [UIImage imageNamed:@"2StarsSmall.png"]; case 3: return [UIImage imageNamed:@"3StarsSmall.png"]; case 4: return [UIImage imageNamed:@"4StarsSmall.png"]; case 5: return [UIImage imageNamed:@"5StarsSmall.png"]; } return nil; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [self.players removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; } }
I have added the following delegate methods and it works great when I scroll the cell.
-(void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath { PlayerCell *cell = (PlayerCell *)[tableView cellForRowAtIndexPath:indexPath]; cell.ratingImageView.hidden = YES; } - (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath { PlayerCell *cell = (PlayerCell *)[tableView cellForRowAtIndexPath:indexPath]; cell.ratingImageView.hidden = NO; }
... but these methods are not called when the editButtonItem button is clicked! This is strange! I'm missing something. I added the following method, which is called when the "Edit / Finish" button is clicked, but there is no way to detect the cell that will be selected for editing!
- (void)setEditing:(BOOL)editing animated:(BOOL)animate { [super setEditing:editing animated:animate]; if(editing) { NSLog(@"editMode on"); } else { NSLog(@"Done leave editmode"); } }
When the user clicks the round button on the left, is there a way to add a selector to this button and get the cell index?

source share