Customizing self.editButtonItem with Check and UnCheck- HELP
Asked Answered
X

2

0

So with regards to the rightBarButtonItem . I have

self.navigationItem.rightBarButtonItem = self.editButtonItem;

When I press Edit, I get animation and a vertical stripe on the left side of each TableViewCell. When I click that stripe, the Delete button appears on the right side of THAT tableViewCell.

I want to do two things.

  1. Rename that 'Delete' to 'Check'
  2. If it is checked, it should display 'Uncheck' to be tapped.

I would appreciate any help on that..

:)

Xyster answered 2/6, 2011 at 19:19 Comment(0)
T
3

Implement tableView:titleForDeleteConfirmationButtonForRowAtIndexPath: in your table view delegate.

Trilinear answered 2/6, 2011 at 19:33 Comment(2)
That was a Wicked Answer ! Thanks. Could you also let me in with the logic for setting up the UnCheck button if it is checked ?Xyster
Dan, I got it. Thanks for the tip though.Xyster
X
1

For the second part of the answer I did this.

if (editingStyle == UITableViewCellEditingStyleDelete) {

 UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

 if (selectedCell.accessoryType == UITableViewCellAccessoryNone)
 {
     selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
 }
 else 
     if (selectedCell.accessoryType == UITableViewCellAccessoryCheckmark)
     {
         selectedCell.accessoryType = UITableViewCellAccessoryNone;
     }

}   

and

- (NSString *) tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

if (selectedCell.accessoryType == UITableViewCellAccessoryNone)
{

    return (@"Check");
}
else 
    if (selectedCell.accessoryType == UITableViewCellAccessoryCheckmark)
    {

        return (@"UnCheck");
    }

}
Xyster answered 2/6, 2011 at 20:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.