From bdab13209c990736c0b3c6b5a37e778e762195d5 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Sun, 25 Apr 2021 15:48:20 +0800 Subject: [PATCH] iOS: fix callback error.Use item's node instead --- doric-iOS/Pod/Classes/Shader/DoricListNode.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricListNode.m b/doric-iOS/Pod/Classes/Shader/DoricListNode.m index a96cfa65..1f53f477 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricListNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricListNode.m @@ -192,13 +192,16 @@ - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *) NSArray *actions = self.itemActions[@(indexPath.row)]; NSMutableArray *array = [NSMutableArray new]; for (NSDictionary *action in actions) { - __weak typeof(self) _self = self; UITableViewRowAction *tableViewRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:action[@"title"] handler:^(UITableViewRowAction *tableViewRowAction, NSIndexPath *indexPath) { - __strong typeof(_self) self = _self; - [self callJSResponse:action[@"callback"], nil]; + UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; + if ([cell isKindOfClass:DoricTableViewCell.class]) { + [((DoricTableViewCell *) cell).doricListItemNode callJSResponse:action[@"callback"], nil]; + } else { + DoricLog(@"Cannot find table cell"); + } }]; [action[@"backgroundColor"] let:^(id it) { tableViewRowAction.backgroundColor = DoricColor(it); @@ -212,13 +215,16 @@ - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView tra NSArray *actions = self.itemActions[@(indexPath.row)]; NSMutableArray *array = [NSMutableArray new]; for (NSDictionary *action in actions) { - __weak typeof(self) _self = self; UIContextualAction *contextualAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:action[@"title"] handler:^(UIContextualAction *_Nonnull contextualAction, __kindof UIView *_Nonnull sourceView, void (^_Nonnull completionHandler)(BOOL)) { - __strong typeof(_self) self = _self; - [self callJSResponse:action[@"callback"], nil]; + UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; + if ([cell isKindOfClass:DoricTableViewCell.class]) { + [((DoricTableViewCell *) cell).doricListItemNode callJSResponse:action[@"callback"], nil]; + } else { + DoricLog(@"Cannot find table cell"); + } }]; [action[@"backgroundColor"] let:^(id it) { contextualAction.backgroundColor = DoricColor(it);