title: UIView addsubview after orientation change: Tell view to resize
body: <p>I have a UIView as a XIB in Portrait mode.</p>
  
  <p>This view is added programmatically to the viewcontroller like this:</p>
  
  <pre><code>NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"InputView" owner:self options:nil];
      InputView *inputView = (InputView*)[nibObjects objectAtIndex:0];
      [self.view addSubview:inputView];
  </code></pre>
  
  <p>This view has autoresizing masks set up properly and rotates fine when the orientation changes from Portrait to landscape.</p>
  
  <p>However, if the orientation is <em>already</em> landscape and I create the view <em>after</em> the orientation change, it has its initial portrait orientation. </p>
  
  <p>Is there a way to tell the view to initialize or resize itself to portrait by using its masks?</p>
  
  <p>Thanks in advance for any reply!</p>
  
  <p>EDIT:
  Using the suggestions of occulus and Inder Kumar Rathore (thanks guys!), I altered the code to this:</p>
  
  <pre><code>InputView *inputView = (InputView*)[nibObjects objectAtIndex:0];
  [self.view addSubview:inputView];
  [self.view setNeedsLayout];
  [self.view layoutSubviews];
  [self.view layoutIfNeeded];
  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
  [self shouldAutorotateToInterfaceOrientation:orientation];
  </code></pre>
  
  <p>Unfortunately, there is no change at all. 
  I think I found someone asking the same question:</p>
  
  <p><a href="https://stackoverflow.com/questions/5161894/when-adding-a-sub-view-the-view-does-not-resize-if-the-app-is-in-landscape-mode">When adding a sub view the view does not resize if the app is in landscape mode</a></p>
  
  <p>The answer identifies the problem correctly, but is not very encouraging...
  Sure, I could create two nibs or resize the frame, but this seems so contrary to the idea of auto-resizing.
  I find it hard to believe that there is no way to tell a nib after awakening and adding it to a view to use its autoresize features...something that works flawless when the device rotates. </p>
  
  <p>EDIT 2:</p>
  
  <p>The solution of idz works:</p>
  
  <pre><code>InputView *inputView = (InputView*)[nibObjects objectAtIndex:0];
  [self.view addSubview:inputView];
  inputView.frame = self.view.bounds;
  [inputView show];
  </code></pre>
  
  <p>Thanks!</p>