views:

65

answers:

1

hi every one.i am using TableView having edit button to delete a row.when i swipe in the row it shows a default "Delete" button. But i dont need it.The Content of the cell must be deleted by means of edit button not by default one.how to disable that "Swipe to Delete" Button.

+2  A: 

Override editingStyleForRowAtIndexPath:

- (UITableViewCellEditingStyle)tableView:(UITableView*)aTableView
           editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.editing)
        return UITableViewCellEditingStyleDelete; //or whatever

    return UITableViewCellEditingStyleNone;
}
eman
thanks but this suggestion also disables my edit buttons functionality
venkat
(see updated example)
eman
thanks it works....But i would like to check weather the cell is empty or not.Because providing delete button for empty cell is not a logic...Thanks for the replies eman...
venkat
is it possible to disable or turn off swipe gesture for specific view?
venkat
Yes--just use the `indexPath` argument to customize the behavior. (The whole method goes in your table view delegate, usually your `UITableViewController` subclass, and it will only apply to that table view).
eman
thanks. i set the indexpath condition.but now it shows both "swipe to delete"and my edit buttons.- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ if([contentArray count] >= (indexPath.row+1)){ return UITableViewCellEditingStyleDelete; } elsereturn UITableViewCellEditingStyleNone;}
venkat
I don't quite understand what you're trying to do, but your problem is in `if([contentArray count] >= (indexPath.row+1))`--this looks to me like it will always return true.
eman
if we HAVE 5 rows in table, it will only show the delete button for the value which available in that cell[contentArray]. (i.e) 5 cells in table but only 2 cells have the value and other 3 will empty. it shows the delete button for the cell containing text(here 2).will not show for the remAINING 3 CELLS.
venkat
simply how to disable that "swipe to delete"button from my table view or else how to turn off swipe gesture for that view.
venkat
hai i solved the problem... thanks for ur kind guidance... bye
venkat
If you found this answer helpful, please press the ✔ next to it.
Emil