2010-12-17 48 views
0

我想加載與shouldAutorotateToInterfaceOrientation方法的視圖,但我有一個問題。當設備以橫向模式運行時,我想要顯示主視圖本身,以及當設備是縱向時,加載自定義UIView。加載主視圖與shouldAutorotateToInterfaceOrientation

這裏是我的代碼:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 

     if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)|| (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) 

      //doesn't show main view !! 
      self.view; 


     else if ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) 

      //works fine ! 
      self.view = portraitView; 


     return YES; 

} 
+0

我想通了!!!!我用一種方法的模態來稱呼我的觀點。 – Momi 2010-12-17 21:09:22

回答

0

我想通了!!!!只是調用視圖與模式上的方法

- (void) mainView { 
    screenTestViewController *mv = [[screenTestViewController alloc]initWithNibName:@"screenTestViewController" bundle:nil]; 
    [self presentModalViewController:mv animated:NO]; 

} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

    // Return YES for supported orientations 

    if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft)|| (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) 

     [self mainView]; 


. 
. 
. 
0

你應該把你的自定義的UIView在:willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration