1

I am using my application delegate to swap out views. First I remove the current view, then I add the new view, then I run a quartz animation.

No matter what view I load first, the orientation changes occur as expected. As soon as I start adding new views (removing the old) to the window in the application delegate, orientation changes no longer happen. Assume shouldAutorotateToInterfaceOrientation is present with YES in all my UIViewControllers.

I took out the quartz animation and here is where I am still stuck:

-(void) showSongList {
  [songVC.view removeFromSuperView];
  navVC = [[NavigationViewController alloc] initWithNibName:0 bundle:0];
  [window addSubView:navVC.view];
  [songVC release];
  songVC = nil;
}

Switch views works fine. The first view always responds and switches orientation, then any changes I make to the window adding views (always removing the previous), diminishes the orientation changes.

If I load navVC right away it will rotate orientation, but when it's further down the line from a button event, I get the orientation problem I've described.

NSLog(@"subview count = %d", [[window subviews] count]); //always 1

I have tried using NSLog in didRotateFromInterfaceOrientation and this function obviously is only called when an orientation change occurs.

My app delegate window always only has one subview, so I'm lost!

4

1 回答 1

1

OK, so I figured out what to do ... I created a UIViewController called SwapViewController and added my other views to that.

I thought that this didn't work, when I first tried because I went straight ahead and added a UIView programmatically. But I guess, given UIViewController has the orientation functions, a view controller was required.

So, make one swap view controller and add subviews to that!

于 2010-02-24T20:38:36.260 回答