Skip to content

Commit 70da769

Browse files
doumafangYorkShen
authored andcommitted
* [iOS] fix scrollTo wrong position when no virtalElementInfo
1 parent 53a9e02 commit 70da769

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ios/sdk/WeexSDK/Sources/Component/RecycleList/WXRecycleListComponent.mm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ - (void)scrollTo:(NSString *)virtalElementInfo options:(NSDictionary *)options
383383
}
384384
else
385385
{
386+
if (virtalElementInfo.length == 0) {
387+
return;
388+
}
386389
position = [self _positionForVirtalElementInfo:virtalElementInfo];
387390
}
388391
NSIndexPath *toIndexPath = [NSIndexPath indexPathForItem:position inSection:0];
@@ -408,13 +411,19 @@ - (void)queryElementAll:(NSString *)virtalElementInfo cssSelector:(NSString *)cs
408411
- (NSString *)_refForVirtalElementInfo:(NSString *)virtalElementInfo
409412
{
410413
NSArray *stringArray = [virtalElementInfo componentsSeparatedByString:@"@"];
411-
return stringArray[0];
414+
if (stringArray.count == 2) {
415+
return stringArray[0];
416+
}
417+
return nil;
412418
}
413419

414420
- (NSUInteger )_positionForVirtalElementInfo:(NSString *)virtalElementInfo
415421
{
416422
NSArray *stringArray = [virtalElementInfo componentsSeparatedByString:@"@"];
417-
return [stringArray[1] integerValue];
423+
if (stringArray.count == 2) {
424+
return [stringArray[1] integerValue];
425+
}
426+
return 0;
418427
}
419428

420429
- (void)closest:(NSString *)virtalElementInfo cssSelector:(NSString *)cssSelector callback:(WXModuleCallback)callback

0 commit comments

Comments
 (0)