iOS: impl scroll to item with top offset api
This commit is contained in:
parent
79cef25191
commit
3dd44cf9f7
@ -663,7 +663,18 @@ - (void)scrollToItem:(NSDictionary *)params {
|
|||||||
for (int i = 0; i <= scrolledPosition; i++) {
|
for (int i = 0; i <= scrolledPosition; i++) {
|
||||||
[self calculateCellHeightItemNode:node atIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
|
[self calculateCellHeightItemNode:node atIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
|
||||||
}
|
}
|
||||||
[self.view scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:scrolledPosition inSection:0] atScrollPosition:UITableViewScrollPositionNone animated:animated];
|
|
||||||
|
if (params[@"topOffset"] != nil) {
|
||||||
|
CGFloat topOffset = [params[@"topOffset"] floatValue];
|
||||||
|
[self.view layoutIfNeeded];
|
||||||
|
NSIndexPath *targetIndexPath = [NSIndexPath indexPathForRow:scrolledPosition inSection:0];
|
||||||
|
CGRect rect = [self.view rectForRowAtIndexPath:targetIndexPath];
|
||||||
|
CGPoint newContentOffset = CGPointMake(self.view.contentOffset.x, rect.origin.y + topOffset);
|
||||||
|
|
||||||
|
[self.view setContentOffset:newContentOffset animated:animated];
|
||||||
|
} else {
|
||||||
|
[self.view scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:scrolledPosition inSection:0] atScrollPosition:UITableViewScrollPositionNone animated:animated];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
[self.doricContext.driver.registry onLog:DoricLogTypeError
|
[self.doricContext.driver.registry onLog:DoricLogTypeError
|
||||||
|
Reference in New Issue
Block a user