Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This drove me absolutely nuts too. I did a couple of things that made it work, but I'm not happy about my solutions -- 1) I don't really understand it and 2) it seems hacky.</p> <p>I added this to my app delegate (my .m file):</p> <pre><code>@interface UITabBarController (MyApp) @end @interface UINavigationController (MyApp) @end @implementation UITabBarController (MyApp) - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return YES; } @end @implementation UINavigationController (MyApp) - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return YES; } @end </code></pre> <p>This worked for the most part. For the views that didn't auto-rotate though, I had to manually rotate the views myself using transforms. I did something like:</p> <pre><code>- (void)deviceOrientationDidChangeWithAnimation:(BOOL)animated { UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if (orientation == oldOrientation) { return; } if (animated) { CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:duration]; [UIView setAnimationDidStopSelector:@selector(orientationChanged)]; } [self sizeToFitOrientation:YES]; if (animated) { [UIView commitAnimations]; } oldOrientation = orientation; } - (CGAffineTransform)transformForOrientation { UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if (orientation == UIInterfaceOrientationLandscapeLeft) { return CGAffineTransformMakeRotation(M_PI*1.5); // rotated CCW } else if (orientation == UIInterfaceOrientationLandscapeRight) { // CW return CGAffineTransformMakeRotation(M_PI/2); } else if (orientation == UIInterfaceOrientationPortraitUpsideDown) { // CCW return CGAffineTransformMakeRotation(-M_PI); } else { // CW return CGAffineTransformIdentity; } } - (void)sizeToFitOrientation:(BOOL)transform { if (transform) { self.view.transform = CGAffineTransformIdentity; } CGRect frame = [UIScreen mainScreen].applicationFrame; CGPoint center = CGPointMake(frame.origin.x + ceil(frame.size.width/2), frame.origin.y + ceil(frame.size.height/2)); CGFloat width = frame.size.width - 0 * 2; CGFloat height = frame.size.height - 0 * 2; UIInterfaceOrientation _orientation = [UIApplication sharedApplication].statusBarOrientation; if (UIInterfaceOrientationIsLandscape(_orientation)) { self.view.frame = CGRectMake(0, 0, height, width); } else { self.view.frame = CGRectMake(0, 0, width, height); } self.view.center = center; if (transform) { self.view.transform = [self transformForOrientation]; } } </code></pre> <p>Hope this helps! And if someone can point out mistakes I've made (or bad things I'm perpetuating), I'd be happy to learn. :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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