Changing iphone orientation, then changing it back cuts my view in half?
<p>I have a view controller in my iphone app setup so that when I change the orientation from portrait to landscape, I change the view. When I change the orientation back from landscape to portrait, the initial view comes back, except this time it is all crammed into the left hand side of the screen. Eventually, when I change orientations enough times everything disappears completely. Is this a common issue beginners have? What could I be doing wrong? </p>

<p>In my root controller I am allowing the orientation to change only when a specific view is being shown with this:</p>

<pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (self.currentView == (NSInteger*)Chart || self.currentView == (NSInteger*)Detail) {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
return (interfaceOrientation == UIInterfaceOrientationPortrait);
</code></pre>

<p>Where <code>self.currentView</code> is an enum of what view I currently have up. The Detail view I want to make sure stays as a portrait view, but when I change the orientation while on that view I want it to change the view to the Graph. Again, this works fine the first time, but when I change back from Graph to Detail, it crams all the controls on the Detail view to the left hand side of the screen.</p>

<p>Here is how I'm changing the view:</p>

<pre><code>- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

if (self.currentView == (NSInteger*)Detail &amp;&amp; (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"changeView" object:self userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:Chart] forKey:@"view"]];
}

if (self.currentView == (NSInteger*)Chart &amp;&amp; (toInterfaceOrientation == UIInterfaceOrientationPortrait)) {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"changeView" object:self userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:Detail] forKey:@"view"]];
}
</code></pre>
