views:

302

answers:

1

Hi developer friends,

I want a little help. I have a view which has it's own navigation bar and one tableview. I want to edit & delete item in that table view. I have placed and edit button on the navigation bar like this.

self.navItem.leftBarButtonItem = self.editButtonItem;

And also have one method like this.

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

if(editingStyle == UITableViewCellEditingStyleDelete) {

 //Get the object to delete from the array.

 //Delete the object from the table.
 [self.tblView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

}

But when I am clicking on that button, none of the item in tableview turns with that red mark icon. Just caption of edit button changes to "Done".

What should be the problem?

A: 

Is this a UIViewController, or a UITableViewController? It would appear (from self.tblView in the attached code) that you're using a standard UIViewController. In this case, you have to implement setEditing:animated: in your view controller, which, in turn, should call that in your table view.

Ben Gottlieb
yes I have placed a UITableView in a UIVIewController. And one navigation bar also. So, can you please explain me this in more detail, if possible with example.
Ruchir Shah
I am done with that. thanks.
Ruchir Shah