I can set the edit mode for a while uitableview by calling [tableView setEditing:YES]; But that sets the edit mode for all the rows in a table.
Is there a way to detect what row was swiped an enable the edit mode only for that row?
Thanks
I haven't coded this up, but here's the idea.
Create selectionIndexPath in .h
NSIndexPath *selectionIndexPath;
Then in .m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
save indexPath to selectionIndexPath and call:
[self.tableView setEditing:YES];
Then in:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
if (selectionPath.row == indexPath.row)
{
return UITableViewCellEditingStyleDelete;
}
else
{
return UITableViewCellEditingStyleNone;
}
}
You could also catch the touches and then do more or less the same thing. Something like this...
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil)
{
// save indexPath and setEditing Mode here
}
Didn't have any time to code it up, but that's the main idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With