Do you scroll horizontally or vertically? your bias logic
CGPointMake((index * (self.view.frame.size.width)), 0); will move to 0 on the y axis. CHANGE
I was lazy writing the approach.
Here is the approach I take to find related questions:
a) program offset is set by setContentOffset :, scrollRectToVisible, setFrame (from UIScrollView, internally calls SetContentOffset). First check all this in your code if they are correct.
b) print the Logs for offset parameters set in the scrollViewDidScroll: method.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { NSLog(@" Offset = %@ ",NSStringFromCGPoint(scrollView.contentOffset)); }
This will help you determine the set offset values (in most cases, the required offset is overridden by another call to setContentOffset: somewhere in the code, it allows you to say that the current offset (130.0), and you want to set the offset (300.0) in steps (if they are animated), you can get logs, for example, Offset = {130,0}
Offset = {190,0}
Offset = {220,0}
Offset = {270,0}
Offset = {300,0} Offset = {130,0}
Offset = {190,0}
Offset = {220,0}
Offset = {270,0}
Offset = {300,0}
If there is another call to setContentOffset (animated), you can say that it sets the offset to (0,0), the logs you get will look like Offset = {130,0}
Offset = {190,0}
Offset = {90, 0}
Offset = {220,0}
Offset = {60,0}
Offset = {270,0}
Offset = {30,0}
Offset = {300,0}
Offset = {0,0} Offset = {130,0}
Offset = {190,0}
Offset = {90, 0}
Offset = {220,0}
Offset = {60,0}
Offset = {270,0}
Offset = {30,0}
Offset = {300,0}
Offset = {0,0}
If you notice the second pattern in the logs, you can be sure that there is an incorrect call to setContentOffset.
3) After you have determined that there is an unintended call to setContentOffset, try to find its source (setting a breakpoint for setContentOffset may help) and can be considered in each case. eg:
_adjustContentOffsetIfNecessary , is an internal method called when a frame is set for UIScrollView. This may be the reason (try applying the previous offset after setting the frame).
Hope this helps (also when removing down) :)