I am working on an application that works fully in landscape mode (UIStatusBarHidden = YES and UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight). I am using NavigationController with setting rootViewController (MainViewController) as follows:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
In my MainViewController, I load the view as follows:
- (void)loadView {
CGRect frame = [[UIScreen mainScreen] applicationFrame];
MainView *view = [[MainView alloc] initWithFrame:frame];
self.view = view;
[view release];
}
Then in MainView, I load subviews as follows:
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.pdfView = [[PDFView alloc] initWithFrame:frame];
[self addSubview:pdfView];
}
returnself;
}
My problem is that MainView correctly displays in landscape mode (despite the fact that the frame passed to [MainView initWithFrame:] in the portrait), while the child PDFView turns into a portrait frame. I also experimented with transforms in my implementations of [UIView initWithFrame:] as follows:
view.center = CGPointMake(view.frame.size.height/2.0, view.frame.size.width/2.0);
view.transform = CGAffineTransformRotate(view.transform, (M_PI/2.0));
, . , , , :
CGRectMake(0.0, 0.0, 480.0, 320.0)
, .
?