In a iPhone application, I am using two different tableviews in same screen. Now, I want to use the swipe-delete functionality in one table view but not in the other. But when I call the delegate method 'commiteditingstyledelete' to get the swipe-delete button in both the table view. How to remove that from the other table ? I can not disable the row user-interaction as I have some textfield in tableview row. Please suggest.
In your delegate callback for editing cells, you have to check what table you want to use, you can set a tag to each tableView, or you're using ivars check for the instance, so:
1: with ivars
if(tableView==yourTableViewClassVar){
//your table
}
2: with tag
set the tag
tableView.tag=10;
...then in the callback
if(tableView.tag==10){
//your table
}
EDIT:
The problem is , even when I swipe across Table2, the commiteditingstyle method is called and shows the delete button.
you also have to check set style of the cell in this callback:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView.tag==10) {
return UITableViewCellEditingStyleNone;
}else{
return UITableViewCellEditingStyleDelete;
}
}
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