Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scroll to a certain point in a UIScrollView

Below I have a line of code that scrolls to a certain point in a UIScrollView. However once it has scrolled there it does not allow me to scroll back up.

[scroller setContentOffset:CGPointMake(0,500) animated:NO];

Any help will be appreciated, thank you.

like image 718
Tom Avatar asked Dec 21 '25 09:12

Tom


1 Answers

did you try using UIScrollView method scrollRectToVisible: Here is an example

- (void)goToPage:(int)page animated:(BOOL)animated
{
    CGRect frame;
    frame.origin.x = self.scroller.frame.size.width * page;
    frame.origin.y = 0;
    frame.size = self.scroller.frame.size;
    [self.scroller scrollRectToVisible:frame animated:animated];

    // update the scroll view to the appropriate page
}
like image 97
Anshul Jain Avatar answered Dec 23 '25 01:12

Anshul Jain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!