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
2010-04-23 05:10:03
thanks but this suggestion also disables my edit buttons functionality
venkat
2010-04-23 05:19:09
(see updated example)
eman
2010-04-23 05:23:24
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
2010-04-23 05:29:30
is it possible to disable or turn off swipe gesture for specific view?
venkat
2010-04-23 05:39:59
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
2010-04-23 06:16:51
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
2010-04-23 06:34:04
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
2010-04-23 07:05:43
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
2010-04-23 07:22:44
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
2010-04-23 07:24:24
hai i solved the problem... thanks for ur kind guidance... bye
venkat
2010-04-26 05:24:53
If you found this answer helpful, please press the ✔ next to it.
Emil
2010-06-24 09:07:25