I have a UIScrollView which is the same width as its superview. It has a very wide contentSize and scrolls horizontally.
I am trying to use the delegate method scrollViewWillEndDragging:withVelocity:targetContentOffset: to set targetContentOffset->x to a negative value (i.e. move the left edge of the content area closer to the center of the screen).
Setting the value seems to work (NSLog shows a change before and after) but the scrollview seems to ignore the modified targetContentOffset and just ends scrolling at 0.
-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
NSLog(@"target: %@", NSStringFromCGPoint(*targetContentOffset));
if (targetContentOffset->x <= 0.0)
{
targetContentOffset->x = -300;
}
NSLog(@"target: %@", NSStringFromCGPoint(*targetContentOffset));
}
Does anybody know if this can be done using this method or should I be doing it some other way?