Bugra Baskaya
Bugra Baskaya

Reputation: 53

Red minus sign is not appearing when I hit edit button

I did add this code to my viewDidLoad, the edit button showed up, but there is no minus button at the left side of the rows.

  self.navigationItem.leftBarButtonItem = self.editButtonItem;   

After swiping the row, the delete button shows up, but when I hit the edit button there is no minus sign.

What can cause the minus sign to not show up in my program?

Upvotes: 5

Views: 2118

Answers (1)

iDev
iDev

Reputation: 23278

Set your table view editing mode as,

   [self.tableView setEditing:YES animated:YES];

do the above in the action method of your edit button in navigation bar.

Or just use,

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];
    [self.tableView setEditing:editing animated:animated];
}

If you want to show the delete button, you can implement the below code.

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath

     return UITableViewCellEditingStyleDelete;
}

For more details check the apple documentation

Upvotes: 5

Related Questions