Cocoa touch 处理交换视图的设备方向问题

Cocoa touch 处理交换视图的设备方向问题,cocoa-touch,uiinterfaceorientation,Cocoa Touch,Uiinterfaceorientation,我正在做一个ipad应用程序,其中有两个视图 mainview和aboutus视图 启动时,我将mainview单独放在rootcontroller的视图(添加到窗口的视图)中。 mainview上有一个按钮,当按下该按钮时,将从superview中删除mainview,并放置AboutsView。aboutus有一个类似的按钮,让我们回到mainview 现在问题在于旋转(方向)。 当我检测到方向改变时,我会更新显示的视图。很好。(适用于mainview和AboutView) 但如果我旋转一次

我正在做一个ipad应用程序,其中有两个视图 mainview和aboutus视图 启动时,我将mainview单独放在rootcontroller的视图(添加到窗口的视图)中。 mainview上有一个按钮,当按下该按钮时,将从superview中删除mainview,并放置AboutsView。aboutus有一个类似的按钮,让我们回到mainview

现在问题在于旋转(方向)。 当我检测到方向改变时,我会更新显示的视图。很好。(适用于mainview和AboutView) 但如果我旋转一次任何视图,然后尝试查看第二个视图。第二个视图似乎不是自动调整大小

rootViewController中的代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
 _currentOrientation=UIDeviceOrientationPortrait;
 [self.view addSubview:_mainView];
 [_splashView removeFromSuperview];
}

-(void)viewDidAppear:(BOOL)animated
{
 _currentView = _mainView;
}

-(void)toggleMainPage
{
 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:.5];
 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[self view] cache:YES];
 [_infoView removeFromSuperview];
 [self.view addSubview:_mainView];
 _currentView=_mainView;
 [self transformViewAccordingToOrientation:_currentOrientation];
 [UIView commitAnimations];

}

-(void)toggleAboutPage
{
 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:.5];
 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view] cache:YES];
 [_mainView removeFromSuperview];
 [self.view addSubview:_infoView];
 _currentView=_infoView;
 [self transformViewAccordingToOrientation:_currentOrientation];
 [UIView commitAnimations];
}

-(void) transformViewAccordingToOrientation:(UIDeviceOrientation)toInterfaceOrientation
{
 if(toInterfaceOrientation == UIDeviceOrientationPortrait)
 {
  [_mainBtnCustom setBackgroundImage:[UIImage imageNamed:@"main.png"] forState:UIControlStateNormal];
  _infoImage.image =  [UIImage imageNamed:@"about.png"];

 }else
 {

  [_mainBtnCustom setBackgroundImage:[UIImage imageNamed:@"mainr.png"] forState:UIControlStateNormal];
  _infoImage.image =  [UIImage imageNamed:@"aboutr.png"];
 }
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
 [self transformViewAccordingToOrientation:toInterfaceOrientation];
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
 _currentOrientation = [UIDevice currentDevice].orientation;
 [self transformViewAccordingToOrientation:_currentOrientation];
}


// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
 return (_currentOrientation !=interfaceOrientation);
}
我做错了什么