#if !TARGET_OS_MACCATALYST
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView
editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *action_reuse =
[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
title:@"Utiliser"
handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
[self reutiliser:indexPath];
}];
action_reuse.backgroundColor = [UIColor systemTealColor];
UITableViewRowAction *action_suppr =
[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive
title:@"Supprimer"
handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
[self supprimer:indexPath];
}];
action_suppr.backgroundColor = [UIColor systemRedColor];
return @[ action_suppr, action_reuse ];
}
#endif
#if TARGET_OS_MACCATALYST
/* UISwipeActionsConfiguration available IOS11 */
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView
trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath {
NSMutableArray<UIContextualAction*>* actions = [NSMutableArray new];
[actions addObject:[UIContextualAction
contextualActionWithStyle:UIContextualActionStyleNormal
title:@"Utiliser"
handler:^(UIContextualAction *action
, __kindof UIView *sourceView,
void(^completionHandler)(BOOL actionPerformed)){
[self reutiliser:indexPath];
completionHandler(true);
}]];
[actions addObject:[UIContextualAction
contextualActionWithStyle:UIContextualActionStyleDestructive
title:@"Supprimer"
handler:^(UIContextualAction *action
, __kindof UIView *sourceView,
void(^completionHandler)(BOOL actionPerformed)){
[self supprimer:indexPath];
completionHandler(true);
}]];
return [UISwipeActionsConfiguration configurationWithActions:actions];
}
#endif
Commentaires