您好我正在制作基于导航的应用程序,我想要旋转子视图控制器我正在使用以下代码但是当我旋转设备时这些功能无法调用
- (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 :(得分:0)
如果您已将此子视图控制器添加为子视图,则不会调用这些方法。但是这些UIViewController
方法将在父视图控制器中调用
答案 1 :(得分:0)
如果您已将此子视图控制器添加为子视图,则不会调用这些方法。
它在父视图(rootview)中的唯一调用。
答案 2 :(得分:0)
当你return (interfaceOrientation == UIInterfaceOrientationPortrait);
时,你告诉视图控制器它不应该旋转到除了肖像之外的任何方向。如果您希望它旋转到所有方向,请从YES
shouldAutorotateToInterfaceOrientation: