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?
['https://Stackoverflow.com/questions/3647548', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/143378/']
Converting my comment to an answer :)

Try changing `contentOffset` from within `willAnimateRotationToInterfaceOrientation:duration:` instead. An animation block should be in place by then, and the OS regards your changes to contentOffset as belonging to the changes caused by the rotation.

If you change contentOffset before, it looks like the system doesn't respect these changes as belonging to the rotation, and still applies rotation-resizing, this time starting from your new dimensions.
Updated answer for iOS 8+

Implement viewWillTransitionToSize:withTransitionCoordinator: in your controller.

Example:

```
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    NSUInteger visiblePage = (NSInteger) self.scrollView.contentOffset.x / self.scrollView.bounds.size.width;

    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
        self.scrollView.contentOffset = CGPointMake(visiblePage * self.scrollView.bounds.size.width, self.scrollView.contentOffset.y);
    } completion:nil];
}

```