3
votes

Basically I have a uiscrollview. The uiscrollview scrolls down when i push a certain button. However once the content offset has been set it will not allow me to scroll the uiscrollview back to the to. For example... If I set the content off set to 100 and animated:yes. The scrollview will scroll to that position and allow me to continue to scroll down the page but when trying to scroll up you pull up and see the upper par of the view but it then bounces back down.

Here is my code:

Firstly when the button is pressed I call the void function:

[self downExecute:scroller];

Secondly I run the void statement which set's my content off set...

- (void)downExecute:(id)sender {

    NSLog(@"scroll down");

    CGFloat currentOffset = scroller.contentOffset.y;

    CGFloat newOffset;

    newOffset = currentOffset + 100;

    [UIScrollView animateWithDuration:0.3 animations:^(void) {


        [scroller setContentOffset:CGPointMake(0.0,newOffset)];

    }completion:^(BOOL finished) {



    }];


}

Any Help would be greatly appreciated...

2

2 Answers

2
votes

If your intent is to allow normal scrolling after you've repositioned the content, you could use scrollRectToVisible:animated: instead of changing the content offset.

0
votes

try something like this to allow scrolling:

scroller.alwaysBounceVertical = YES;

and to manage duration of scrolling use this:

scroller.viewForBaselineLayout.layer.speed = 1.0f;  // 1.0f is default
[scroller setContentOffset:(some CGPoint) animated:YES];