Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // i have a cell subclass and i want to be able to select multiple rows for move/delete
  2. // i returned UITableViewCellEditingStyleNone in the delegate method and i added this frame offset where i want to // toogle between 2 images(selected and not selected).
  3.  
  4. UIImageView *aView = [[UIImageView alloc] initWithFrame: CGRectMake(-26 ,8.5 ,26, 27)];
  5. aView.tag = EditTagUnchecked;
  6. [self.contentView addSubview: aView];
  7. self.myImageView = (UIImageView *)[self.contentView viewWithTag: EditTagUnchecked];
  8. [aView release];
  9.  
  10. // in the didSelectRowAtIndexPath i have this implementation to toogle between the images when the user select that row:
  11.  
  12.  
  13. MyCell *cell = (MyCell *)[tableView cellForRowAtIndexPath:indexPath];
  14. if(cell.myImageView.tag == EditTagUnchecked)
  15. {  
  16.     cell.isSelected = YES;
  17.     cell.myImageView.tag = EditTagChecked;
  18.     cell.myImageView.image = [UIImage imageNamed: @"editChecked.png"];
  19. }
  20. else if(cell.myImageView.tag == EditTagChecked)
  21. {
  22.     cell.isSelected = NO;
  23.     cell.myImageView.tag = EditTagUnchecked;
  24.     cell.myImageView.image = [UIImage imageNamed: @"editUnchecked.png"];
  25. }
  26.  
  27. // My problem is when the table is in editing mode,if i select a few cells then scroll down some random cells
  28. // already have the image that should be there only when the row is selected.
  29. // in the cellForRowAtIndexPath i have this implementation:
  30.  
  31. if(self.myTableView.editing)
  32.     cell.myImageView.image = [UIImage imageNamed: @"editChecked.png"];
  33.  
  34. // how can i fix this problem? i think the random images are there because of the reuse of cells instead of create new ones but i am not sure...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement