Save current position in UIScrollView and then scroll to this position

No comments on Save current position in UIScrollView and then scroll to this position

Written by

in

To save a position of the current scroll view use this method:

- (void)savePosition {
    positionY = webView.scrollView.contentOffset.y;
    NSLog(@"positionY:%d", positionY);
}

To scroll programmatically to the saved position use this method:

- (void)scrollToYPosition:(int)positionY {
    [self.webView.scrollView setContentOffset: \
CGPointMake(self.webView.scrollView.contentOffset.x, positionY)];
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *