I have been struggling for hours to add the swipe to delete feature to a plain UITableView in my app without success.
I have a UIViewController containing uniquely a UITableView which uses basic cells and custom cells. This UIViewController is on top of a UINavigationController which is the centerViewController of a IIViewDeckController
The delegate and datasource of the UITableView are set properly and this is the current code :
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"canEditRowAtIndexPath");
return YES;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"commitEditingStyle");
}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"editingStyleForRowAtIndexPath");
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tv didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didEndEditingRowAtIndexPath");
}
Other delegate methods like cellForRowAtIndexPath, canEditRowAtIndexPath and didSelectRowAtIndexPath are called properly but editingStyleForRowAtIndexPath never gets called on any cell.
Update
When I do [table setEditing:YES animated:YES]; it is indeed enabling the editing mode.
What could be missing here ?
The problem was that the swipe event where caught by the IIViewDeckController in order to open the sidebar.
By setting the IIViewDeckController panningMode to IIViewDeckNavigationBarPanning it removes this feature and therefore fix the issue with the UITableView.
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