2011-04-11 124 views
-1

嗨,我想提出基於引導的應用程序,我要旋轉我用下面的代碼子視圖控制器,但是當我旋轉設備,這些功能不能被稱爲旋轉視圖控制器

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

{ 

// return YES; 

return (interfaceOrientation == UIInterfaceOrientationPortrait); 

} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 

{ 

NSLog(@"didRotateFromInterfaceOrientation"); 

if(fromInterfaceOrientation == UIInterfaceOrientationPortrait || fromInterfaceOrientation== UIInterfaceOrientationPortraitUpsideDown) 



{ 

     portraitMode = NO; 

     for(int j=0;j<5;j++) 
      [self unloadPage:j]; 

     [self loadLandScrollViewWithPage:pageInt-1]; 
     [self loadLandScrollViewWithPage:pageInt]; 
     [self loadLandScrollViewWithPage:pageInt+1]; 

     [fullSizeView setHidden:NO]; 

     CGRect frame = l_mageScrollView.frame; 
     frame.origin.x = frame.size.width * pageInt; 
     frame.origin.y = 0; 
     [l_mageScrollView scrollRectToVisible:frame animated:YES]; 
    } 
    else 
    { 
     portraitMode = YES; 

     [fullSizeView setHidden:YES]; 

     for(int j=0;j<5;j++) 
      [self unloadPage:j]; 

     //[l_mageScrollView setHidden:NO]; 
     [self loadScrollViewWithPage:pageInt-1]; 
     [self loadScrollViewWithPage:pageInt]; 
     [self loadScrollViewWithPage:pageInt+1]; 

     CGRect frame = imageScrollView.frame; 
     frame.origin.x = frame.size.width * pageInt; 
     frame.origin.y = 0; 
     [imageScrollView scrollRectToVisible:frame animated:YES]; 
    } 
} 

回答

0

如果添加此子視圖控制器作爲子視圖,那麼這些方法將不會被調用。但是這些UIViewController方法將在父視圖控制器中調用

+0

然後哪個方法可以用於這個 – user503223 2011-04-11 11:46:20

+0

您可以嘗試旋轉父視圖控制器類中的子視圖方法 – visakh7 2011-04-11 11:54:58

0

如果您已將此子視圖控制器添加爲子視圖,則不會調用這些方法。

它只在父視圖(rootview)中調用。

0

當你return (interfaceOrientation == UIInterfaceOrientationPortrait);,你告訴視圖控制器,它不應該旋轉到除了肖像之外的任何方向。如果你想要它旋轉到所有的方向,請從shouldAutorotateToInterfaceOrientation:返回YES

相關問題