From 0a9ababc2dbe996cfa23b91b8a0928ac3c540e2d Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 14 Jun 2023 19:54:08 +0800 Subject: [PATCH] iOS: fix slider's item cannot call onClick after reloaded --- doric-iOS/Pod/Classes/Shader/DoricSliderNode.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m b/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m index 63151c05..83eb4e9c 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricSliderNode.m @@ -317,17 +317,24 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position { if (viewId && viewId.length > 0) { return [self subModelOf:viewId]; } else { - DoricAsyncResult *result = [self pureCallJSResponse:@"renderBunchedItems", @(index), @(self.batchCount), nil]; + NSInteger batchCount = self.batchCount; + NSInteger start = position; + while (start > 0 && self.itemViewIds[@(start - 1)] == nil) { + start--; + batchCount++; + } + DoricAsyncResult *result = [self pureCallJSResponse:@"renderBunchedItems", @(start), @(batchCount), nil]; NSArray *array = [result waitUntilResult:^(JSValue *models) { return [models toArray]; }]; [array enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) { NSString *thisViewId = obj[@"id"]; [self setSubModel:obj in:thisViewId]; - NSUInteger pos = index + idx; + NSUInteger pos = start + idx; self.itemViewIds[@(pos)] = thisViewId; }]; - return array[0]; + viewId = self.itemViewIds[@(position)]; + return viewId && viewId.length > 0 ? [self subModelOf:viewId] : nil; } }