iOS: add protection when scrollToPosition

This commit is contained in:
pengfei.zhou 2022-07-15 14:31:10 +08:00 committed by osborn
parent a79424c1a5
commit 64a370c701

View File

@ -174,7 +174,10 @@ - (void)blendView:(UITableView *)view forPropName:(NSString *)name propValue:(id
self.onScrollEndFuncId = prop; self.onScrollEndFuncId = prop;
} else if ([@"scrolledPosition" isEqualToString:name]) { } else if ([@"scrolledPosition" isEqualToString:name]) {
dispatch_async(dispatch_get_main_queue(), ^{ 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]) { } else if ([@"canDrag" isEqualToString:name]) {
bool canDrag = [prop boolValue]; bool canDrag = [prop boolValue];