2011-03-30 9 views
0

私のアプリケーションにはポートレート駆動のGUIしかありませんが、回転する必要のあるセクションはあります。 デバイスが回転しているときに、現在のView(Controller?)を閉じて、まったく別のView(Controller)に置き換えたいですか? どうすればいいですか?コード例?iPhoneの回転でViewControllerを置換する

+0

だからあなたは新しいのViewControllerをロードしたいですか? – SNR

答えて

2

あなたは、単に.xibファイル内の同じのUIViewControllerで2つの異なる見解を持っており、必要なときにそれらを切り替えることができます。

のは、あなたがのUIViewControllerで2つのビューがあるとしましょう:

  • ViewPortrait
  • ViewLandscape
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    switch (toInterfaceOrientation) 
    { 
     case UIInterfaceOrientationPortrait: 
     case UIInterfaceOrientationPortraitUpsideDown: 
      self.view = self.ViewPortrait; 
      break; 

     case UIInterfaceOrientationLandscapeLeft: 
     case UIInterfaceOrientationLandscapeRight: 
      self.view = self.ViewLandscape;   
      break; 
    } 
} 
0
- (void)didRotate 
{ 
//Create your new view controller here if it doesn't exist. 
//Push or present the view controller 
} 
関連する問題