title: When are views automatically transformed based on their superview?
body: <p>I asked a similar question before, but now I have done some more work on it and have a more refined question.</p>
  
  <p>I have the following code in my applicationDidFinishLaunching:, creating 3 views and adding them as subviews of the window:</p>
  
  <pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application {
      GLViewController* controller = [[GLViewController alloc] init];
      self.glViewController = controller;
      [controller release];
  
      glView = [[GLView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
      glView.controller = glViewController;
      [glView stopAnimation];
      [window addSubview:glView];
  
      invisibleView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
      invisibleView.alpha = 1.0;
      invisibleView.tag = 2;
      // By the definition of UIViewAutoresizing, 0x3F corresponds to resizing in every direction.
      invisibleView.autoresizingMask = 0x3F;
      obstaclesViewController = [[ObstaclesViewController alloc] init];
      obstaclesViewController.view = invisibleView;
      [window addSubview:invisibleView];
  
      viewController = [[GazeIntroViewController alloc] initWithNibName:@"GazeIntroViewController" bundle:[NSBundle mainBundle]];
      [viewController.view setFrame:[[UIScreen mainScreen] bounds]];
      [window addSubview:viewController.view];
      [window bringSubviewToFront:viewController.view];
  
      [window makeKeyAndVisible];
  
      NSLog(@"window: %@", [window description]);
      NSLog(@"window subviews: %@", [[window subviews] description]);
  }
  </code></pre>
  
  <p>The app is supposed to work only in landscape, so I have set it (in the plist) to launch in landscape, which it does. But the last added subview (GazeIntroViewController) appears rotated by 90 deg. (as if the device was still in portrait).</p>
  
  <p>What's really baffling me, is that the first and second view seem ok. If I take out the middle block where I add the invisibleView, then GazeIntroViewController will also come out right. From the NSLogs, I can see that the views that come out right have a transform automatically applied ([0, 1, -1, 0, 0, 0]), but <strong>I don't understand why this transform is applied to some views and not others</strong>, when their parent is the window for all of them.</p>
  
  <p>Output when invisibleView is not added:</p>
  
  <pre><code>2011-07-31 21:00:51.271 GazeDemo[53515:207] window: &lt;UIWindow: 0xa713ab0; frame = (0 0; 768 1024); autoresize = RM+BM; layer = &lt;CALayer: 0xa713b90&gt;&gt;
  2011-07-31 21:00:51.277 GazeDemo[53515:207] window subviews: (
  "&lt;GLView: 0x68bc350; frame = (0 0; 768 1024); layer = &lt;CAEAGLLayer: 0x68bc4e0&gt;&gt;",
  "&lt;UIView: 0x68c3ce0; frame = (0 0; 748 1024); transform = [0, 1, -1, 0, 0, 0]; autoresize = LM+W+RM+TM+H+BM; layer = &lt;CALayer: 0x68c2150&gt;&gt;"
  )
  </code></pre>
  
  <p>Output when invisibleView is added:</p>
  
  <pre><code>2011-07-31 21:11:05.489 GazeDemo[53710:207] window: &lt;UIWindow: 0x689d4d0; frame = (0 0; 768 1024); autoresize = RM+BM; layer = &lt;CALayer: 0x689d5b0&gt;&gt;
  2011-07-31 21:11:05.496 GazeDemo[53710:207] window subviews: (
  "&lt;GLView: 0x689cf50; frame = (0 0; 768 1024); layer = &lt;CAEAGLLayer: 0x689dcb0&gt;&gt;",
  "&lt;UIView: 0x68a05f0; frame = (0 0; 748 1024); transform = [0, 1, -1, 0, 0, 0]; autoresize = LM+W+RM+TM+H+BM; tag = 2; layer = &lt;CALayer: 0x68a06c0&gt;&gt;",
  "&lt;UIView: 0x6b484b0; frame = (0 0; 768 1024); autoresize = LM+W+RM+TM+H+BM; layer = &lt;CALayer: 0x6b4bad0&gt;&gt;"
  )
  </code></pre>