Note that there are some explanatory texts on larger screens.

plurals
  1. POView positioned incorrectly when set to landscape mode
    text
    copied!<p>My iPhone application is navigation-based and contains a lot of portrait-only views and one landscape-only view for viewing images. So I'd like to force this landscape-only view to automatically rotate to lanscape even if device is positioned in portrait mode.</p> <p>So here is what I'w done in that view's controller:</p> <pre><code>// Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); } - (void)viewWillAppear:(BOOL)animated { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES]; [self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; _originalTransform = [[appDelegate navigationController].view transform]; _originalBounds = [[appDelegate navigationController].view bounds]; _originalCenter = [[appDelegate navigationController].view center]; CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90)); landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0); [[appDelegate navigationController].view setTransform:landscapeTransform]; [appDelegate navigationController].view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [appDelegate navigationController].view.bounds = CGRectMake(0.0, 0.0, 480.0, 320.0); [appDelegate navigationController].view.center = CGPointMake (240.0, 160.0); [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight; } } - (void)viewWillDisappear:(BOOL)animated { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES]; [self.navigationController.navigationBar setBarStyle:UIBarStyleDefault]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [[appDelegate navigationController].view setTransform:_originalTransform]; [[appDelegate navigationController].view setBounds:_originalBounds]; [[appDelegate navigationController].view setCenter:_originalCenter]; [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait; } </code></pre> <p>Now I've got that view always shown in lanscape mode. But there is one problem. This view is positioned incorrectly as shown in <a href="http://img696.imageshack.us/img696/5582/screenshot2010011814533.png" rel="nofollow noreferrer">this screenshot</a>.</p> <p>I tried to manually set the frame after rotation but it didn't help. Also I didn't find a complete guide how to set one view to be landscape-only. <strong>Please help me with this problem.</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload