Reputation: 21
I have just a UItableview. Every cell has a accessoryType symbol(>) in the right of a cell and when i touch a tableview cell it push me a new Viewcontroller. Its simple.
Now problem is that, I want in my tableview cell, when i TouchDragInside the accessoryType symbol it will show me a accessory button(Just like delete Button). When i press the delete button. It will delete the cell from the tableview.
Upvotes: 0
Views: 732
Reputation: 1692
You need to implement these two delegate..
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
NSArray *objects = [NSArray arrayWithObjects:indexPath, nil];
[tableView deleteRowsAtIndexPaths:objects withRowAnimation:UITableViewRowAnimationRight];
}
}
Hope this will work for you..
Upvotes: 1