For iOS6+, you could add this to your controller:
- (BOOL)shouldAutorotate {
YES;
}
- (NSUInteger)supportedInterfaceOrientations {
if (<PDF is portrait>)
return UIInterfaceOrientationMaskPortrait;
if (<PDF is landscape>)
return UIInterfaceOrientationMaskLandscape;
return UIInterfaceOrientationMaskAll;
}
Hope this helps.
EDIT:
I am not sure if you need to manually rotate the PDF to get the results you want. In this case you might try with something like:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toOrientation
duration:(NSTimeInterval)duration {
if (toOrientation == UIInterfaceOrientationMaskLandscape)
pdfScrollViewFrame.transform = CGAffineTransformMakeRotation(M_PI/2);
… // handle all other cases here
}
In order to only lock rotation after viewDidAppear
, I would do following:
@interface…
…
@property (nonatomic) BOOL isRotationLocked;
…
@end
@implementation…
…
- (void)viewDidAppear:(BOOL)animated {
…
self.isRotationLocked = YES;
}
- (BOOL)shouldAutorotate {
YES;
}
- (NSUInteger)supportedInterfaceOrientations {
if (self.isRotationLocked) {
if (<PDF is portrait>)
return UIInterfaceOrientationMaskPortrait;
if (<PDF is landscape>)
return UIInterfaceOrientationMaskLandscape;
}
return UIInterfaceOrientationMaskAll;
}
…