Christian Loncle
Christian Loncle

Reputation: 1584

Left delete icons not appearing while UITableview edit mode

I have a core data/ uitableview based app. Actually 80% of the code so far is equal to the Apple Sample app CoreDataRecipes. My problem is that when I enter the edit mode (by pushing the edit button), there are no "delete badges" on the left side of the rows. Bumper.

alt text

The differences in code with CoreDataRecipes:

  1. I have custom UITabelview cell with a nib file instead of code only.
  2. My Tableview is an Outlet inside my class view. So my class RecipeListTableViewController is an UIViewController with Tableview delegates instead of a UITableViewController

What I tried:

alt text

Anyone any ideas? It must be something simple.

Upvotes: 0

Views: 3833

Answers (4)

Ted
Ted

Reputation: 23746

Make sure you have setup the outlet/ delegate/ datasource then these:

-(void)editButtonTapped
{
    [self.tableView setEditing:YES animated:YES];
}



-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete;
}

Upvotes: 0

Karthi
Karthi

Reputation: 111

Since yours is a UIViewController, the tableview doesnt get the setEditing call. Just add:

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

Upvotes: 1

snowcola
snowcola

Reputation: 46

Make sure that

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{

    return YES;
}

If this is not set to return YES then the badges will not be enabled. The default is set to return NO

Upvotes: 3

iPhoneDev
iPhoneDev

Reputation: 1557

I think you have not added the line tableView.editing=YES on clicking the Edit button

Try by setting it!

Upvotes: 1

Related Questions