From 64a370c701bc8ea477f4e555bdcc715ef8509a28 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 15 Jul 2022 14:31:10 +0800 Subject: [PATCH] iOS: add protection when scrollToPosition --- doric-iOS/Pod/Classes/Shader/DoricListNode.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricListNode.m b/doric-iOS/Pod/Classes/Shader/DoricListNode.m index 9bc12272..2dc675b3 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricListNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricListNode.m @@ -174,7 +174,10 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id self.onScrollEndFuncId = prop; } else if ([@"scrolledPosition" isEqualToString:name]) { dispatch_async(dispatch_get_main_queue(), ^{ - [view scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[prop unsignedIntegerValue] inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; + NSUInteger pos = [prop unsignedIntegerValue]; + if (pos < self.rowCount && pos >= 0) { + [view scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:pos inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; + } }); } else if ([@"canDrag" isEqualToString:name]) { bool canDrag = [prop boolValue];