I want to manually update the contentOffset
of an UIScrollView
during rotation changes. The scroll view fills the screen and has flexible width and flexible height.
I'm currently trying to update the contentOffset in willRotateToInterfaceOrientation
, like this:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[Utils logPoint:myScrollView.contentOffset tag:@"initial"];
myScrollView.contentOffset = CGPointMake(modifiedX, modifiedY);
[Utils logPoint:myScrollView.contentOffset tag:@"modified"];
}
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[Utils logPoint:myScrollView.contentOffset tag:@"final"];
}
However, the final value is not the modified value, and it kinda seems to be influenced by it, but it's not evident to me how.
These are some of the results that I get:
initial: (146.000000;-266.000000)
modified: (81.000000;-108.000000)
final: (59.000000;-0.000000)
initial: (146.000000;-266.000000)
modified: (500.000000;500.000000)
final: (59.000000;500.000000)
initial: (146.000000;-266.000000)
modified: (-500.000000;-500.000000)
final: (-0.000000;-0.000000)
How do I update the contentOffset of a scroll view during a rotation change?