I have a paging UIScrollView that pages through multiple full screen images. I am tiling the pages, queuing and dequeuing the UIViews dynamically as the scroll view pages through the collection of images, based on Apple example code.
I have a toolbar button the calls scrollRectToVisible:animated: to move the UIScrollView to a specific image. That works perfectly.
The problem is that if you then do a single touch in the UIScrollView, it scrolls back to the page it was displaying before the button was touched and the scrollRectToVisible:animated: method call scrolled the view.
If your touch is moving, the UIScrollView scrolls as expected, and subsequent touches do not cause the UIScrollView to move back to the original page.
How do I prevent this behavior?
Thanks
jk
You need to use content offset rather than scrollRectToVisible, eg:
where offsetForPageAtIndex looks like this:
This is based off the Apple “photoscroller” example code from WWDC 2010, which had a frameForPagingScrollView that looks like this:
A full copy of that version of the Photoscroller sample code is here:
https://github.com/jogu/WWDC-2010/tree/master/PhotoScroller