Note that there are some explanatory texts on larger screens.

plurals
  1. POAutosizing doesn't work when loading from XIB after rotating
    text
    copied!<p>In my app I add a view loaded from XIB with <code>UIViewAutosizingMaskFlexibleWidth</code> and have the desired result only in one of two cases:</p> <ol> <li>Adding subview on portrait, and rotating to landscape, resizes the subview correctly;</li> <li>Adding subview on landscape do not cause the subview to resize its width the way it does when rotating;</li> </ol> <p>Here is the code:</p> <pre><code>viewMenuList = [[MenuListController alloc] initWithNibName:@"MenuListController" bundle:[NSBundle mainBundle]]; viewMenuList.view.autoresizingMask = UIViewAutoresizingFlexibleWidth; self.view.autoresizesSubviews = YES; [self.view addSubview:viewMenuList.view]; [self.view sendSubviewToBack:viewMenuList.view]; [viewMenuList.view setNeedsLayout]; [viewMenuList.view setNeedsDisplay]; NSLog(@"frame do menu links view %f, %f, %f, %f", self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height); NSLog(@"frame do menu list view %f, %f, %f, %f", viewMenuList.view.frame.origin.x, viewMenuList.view.frame.origin.y, viewMenuList.view.frame.size.width, viewMenuList.view.frame.size.height); </code></pre> <p>The output in the console is:</p> <pre><code>2010-12-07 16:34:22.552 SlideShow_iPad[19352:207] frame do menu links view 0.000000, 0.000000, 1030.000000, 111.000000 2010-12-07 16:34:22.596 SlideShow_iPad[19352:207] frame do menu list view 0.000000, 0.000000, 768.000000, 109.000000 </code></pre> <p>The last line should display an width of 1030, shouldnt it? It does resize to 1030 after rotating to portrait and going back to landscape.</p> <p>The strangest thing is that I do use the same technic in the superview and worked.</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