0
votes

I want to make the scrollRectToVisible:animated: work even when the contentSize is only set to 1 page size.

The reason: I have multiple pages in the UIScrollView but want to maintain the hard-drag provided by the UIScrollView when it is on the edges. If I set the contentSize accordingly to the number of pages I actually have, that hard-drag will be lost.

How I wish it worked:

  • I keep track of which page to go to in "- (void)scrollViewDidScroll:(UIScrollView*)scrollView"
  • I then call "[self.scrollView scrollRectToVisible:frame animated:YES];" in "- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView willDecelerate:(BOOL)decelerate" if the next page number is different than the current one.

What happens: Nothing, the scrollRectToVisible:frame animated:YES does nothing because the contentSize is set to only 1 page width&height. I have tried to set the contentSize to be 2*height before calling the scrollRectToVisible method, and it sort of works, but scrolls back to the current page number.

So my question is, how can I force the UIScrollView to scroll to a certain position or at least emulate that behaviour?

1
If you cannot figure this out, make a small demo project that you post to DropBox, then offer a 50pt bounty to whoever gives you back a "fixed" project.David H

1 Answers

0
votes

I've solved the issue using another method. I keep track of the position in "scrollViewDidScroll" and animate all the UIViews position accordingly. If anyone wants more information about this let me know, but I think it's pretty straight forward and way more simple than what I was trying to achieve before.