Note that there are some explanatory texts on larger screens.

plurals
  1. PORotate UIViewController to counteract changes in UIInterfaceOrientation
    primarykey
    data
    text
    <p>I've been searching a lot on this, and can't find anything to help me.</p> <p>I have a UIViewController contained within another UIViewController. When the parent UIViewController rotates, say from Portrait to LandscapeLeft, I want to make it look as though the child didn't rotate. That is to say. I want the child to have the same orientation to the sky regardless of the parent's orientation. If it has a UIButton that's upright in Portrait, I want the right-side of the button to be "up" in UIInterfaceOrientationLandscapeLeft.</p> <p>Is this possible? Currently, I'm doing really gross stuff like this:</p> <pre><code>-(void) rotate:(UIInterfaceOrientation)fromOrientation: toOr:(UIInterfaceOrientation)toOrientation { if(((fromOrientation == UIInterfaceOrientationPortrait) &amp;&amp; (toOrientation == UIInterfaceOrientationLandscapeRight)) || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) &amp;&amp; (toOrientation == UIInterfaceOrientationLandscapeLeft))) { } if(((fromOrientation == UIInterfaceOrientationLandscapeRight) &amp;&amp; (toOrientation == UIInterfaceOrientationPortraitUpsideDown)) || ((fromOrientation == UIInterfaceOrientationLandscapeLeft) &amp;&amp; (toOrientation == UIInterfaceOrientationPortrait))) { } if(((fromOrientation == UIInterfaceOrientationPortrait) &amp;&amp; (toOrientation == UIInterfaceOrientationLandscapeLeft)) || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) &amp;&amp; (toOrientation == UIInterfaceOrientationLandscapeRight))) { } if(((fromOrientation == UIInterfaceOrientationLandscapeLeft) &amp;&amp; (toOrientation == UIInterfaceOrientationPortraitUpsideDown)) || ((fromOrientation == UIInterfaceOrientationLandscapeRight) &amp;&amp; (toOrientation == UIInterfaceOrientationPortrait))) { } if(((fromOrientation == UIInterfaceOrientationPortrait) &amp;&amp; (toOrientation == UIInterfaceOrientationPortraitUpsideDown)) || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) &amp;&amp; (toOrientation == UIInterfaceOrientationPortrait))) { } if(((fromOrientation == UIInterfaceOrientationLandscapeLeft) &amp;&amp; (toOrientation == UIInterfaceOrientationLandscapeRight)) || ((fromOrientation == UIInterfaceOrientationLandscapeRight) &amp;&amp; (toOrientation == UIInterfaceOrientationLandscapeLeft))) { } } </code></pre> <p>which seems like a perfectly good waste of code. Furthermore, I was planning on using CGAffineTransform (like cited here: <a href="http://www.crystalminds.nl/?p=1102" rel="nofollow noreferrer">http://www.crystalminds.nl/?p=1102</a>) but I'm confused about whether I should change the view's dimensions to match what they will be after the rotation.</p> <p>The big nightmare here is that you have to keep track of a global "orientation" variable. If you don't, the illusion is lost and the ViewController is rotated into whatever.</p> <p>I could really use some help on this, thanks!</p>
    singulars
    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.
 

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