I am creating an iPhone app with a large 360 โโdegree panoramic image. Panorama is a CATiledLayer in a UIScrollView.
I am trying to implement infinite scrolling of an image (horizontal only). I did this by subclassing UIScrollView and implementing setContentOffset: and setContentOffset: animated: and this works great when the user drags the scrollview. However, when the user lifts his finger and the scroll mode slows down, changing the contentOffset parameter causes braking to stop.
- (void)setContentOffset:(CGPoint)contentOffset { CGPoint tempContentOffset = contentOffset; if ((int)tempContentOffset.x >= 5114) { tempContentOffset = CGPointMake(1, tempContentOffset.y); } else if ((int)tempContentOffset.x <= 0) { tempContentOffset = CGPointMake(5113, tempContentOffset.y); } [super setContentOffset:tempContentOffset]; }
Is there a way to change the contentOffset without affecting the slowdown?
It has been suggested here that overriding setContentOffset: (not setContentOffset: animated) fixes this problem, but I can't get it to work.
I also tried scrollRectToVisible: animated: with no success.
Any ideas on how to fix this problem would be greatly appreciated. Thanks!
EDIT:
Code for scrollViewDidScroll:
-(void)scrollViewDidScroll:(PanoramaScrollView *)scrollView { [panoramaScrollView setContentOffset:panoramaScrollView.contentOffset]; }
I also tried this:
-(void)scrollViewDidScroll:(PanoramaScrollView *)scrollView { CGPoint tempContentOffset = panoramaScrollView.contentOffset; if ((int)tempContentOffset.x >= 5114) { panoramaScrollView.contentOffset = CGPointMake(1, panoramaScrollView.contentOffset.y); } else if ((int)tempContentOffset.x == 0) { panoramaScrollView.contentOffset = CGPointMake(5113, panoramaScrollView.contentOffset.y); } }
source share