2011-04-11 108 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

相关问题