UITableView disable confirmation "delete"

This is similar to the questions that ask the way to scroll / delete without confirmation:

Delete UITableView without confirmation

My table view has cells with a set of UITableViewCellEditingStyleDelete. When the tableview is in edit mode, the cells display a red circle icon with an inner one. To delete a cell, the user deletes the red circle and the "Delete" button appears. Then the user must click Delete, which calls tableView:commitEditingStyle:forRowAtIndexPath:

Some of my lines support UITableViewCellEditingStyleInsert. In this case, the cells display a green circle icon with a "+" inside. Touching the circle immediately calls tableView:commitEditingStyle:forRowAtIndexPath:

I would like tableView:commitEditingStyle:forRowAtIndexPath: called immediately when the user clicks the icon of the initial red circle. That is, there is no delete button button.

Any ideas?

Is there a way to provide custom controls that move to the left, like delete / insert? If so, maybe I could use this mechanism?

+4
source share
1 answer

I came up with one solution, but he risks refusing. (Does the undocumented class against the class violate the sdk convention?)

Perhaps someone can improve this?

Basically, in the context of my custom UITableViewCell, I observe the addition of a delete button (not UIButton, unfortunately), and then calls this action UIControlEventTouchUpInside. With a slight delay, so the animation works:

 - (void) addSubview:(UIView *)view { if ([NSStringFromClass([view class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) { UIControl* c = (UIControl*)view; NSArray* actions = [c actionsForTarget: self forControlEvent: UIControlEventTouchUpInside]; [self performSelector: NSSelectorFromString( [actions lastObject] ) withObject: view afterDelay: .25]; return; } [super addSubview: view]; } 
+3
source

Source: https://habr.com/ru/post/1346382/


All Articles