views:

1941

answers:

1

Hello,

I use a UIWebView displaying a PDF file. By default the PDF is displayed in portait mode but the user can rotate the iPhone. The rotation work well, but after being in landscape, the PDF position is not the same as in portrait. Whe I switch back to portrait mode, the scroll is at the "old" position in the PDF.

My controller send to itself a notification during (or after) the rotation:

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];

and didRotate looks like:

- (void)didRotate:(NSNotification *)notification
{   
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    NSInteger position = [[webView stringByEvaluatingJavaScriptFromString:@"window.pageYOffset;"] intValue];
    if ( (orientation == UIDeviceOrientationLandscapeLeft) || orientation == UIDeviceOrientationLandscapeRight)
    {
     NSLog(@"Landscape");
    }
    else
    {
     NSLog(@"Portrait");
    }
}

The question is: how can I use that (or something else, may be it's a wrong way) the have the same position in my PDF file in landscape or portrait mode.

+1  A: 

I found the response :

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[self updateView];
}

Thanks for reading me !

Le_Jax