iPhone:仅具有横向视图和纵向视图的应用程序

iPhone:仅具有横向视图和纵向视图的应用程序,iphone,objective-c,orientation,landscape,portrait,Iphone,Objective C,Orientation,Landscape,Portrait,我正在使用由RootViewController控制的多个UIViewController构建一个应用程序。当前在plist中,应用程序默认为LandscapeRight 假设我有以下文件可以加载到RootViewController中: IntroView(仅限景观右侧) 景观视图(仅限景观右侧) 肖像视图(仅肖像) 我还在RootViewController的shouldAutorotateToInterfaceOrientation中添加了以下内容: -(BOOL)shouldAutoro

我正在使用由RootViewController控制的多个UIViewController构建一个应用程序。当前在plist中,应用程序默认为LandscapeRight

假设我有以下文件可以加载到RootViewController中:

  • IntroView(仅限景观右侧)
  • 景观视图(仅限景观右侧)
  • 肖像视图(仅肖像)
  • 我还在RootViewController的shouldAutorotateToInterfaceOrientation中添加了以下内容:

    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ([currentClass class] == PortraitView.class) {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    
    } else {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    
    }

    所以一切都很好,直到我加载到肖像视图中,并且在视图中将显示我添加了以下内容(类似于

    这产生了一个正确加载的肖像视图,但现在我的问题是,在我的肖像视图中,我有两个子视图,我想在它们之间切换,但因为我旋转了我的视图UIViewAnimationTransitionFlipFromLeft,实际上使它从上到下而不是从左到右翻转。我一辈子都不知道如何告诉肖像视图这不是肖像画

    当我选中[[UIDevice currentDevice]方向]时,它会告诉我它在横向中的位置。当我尝试使用shouldAutorotateToInterfaceOrientation并将其设置为仅纵向时,它会旋转我的视图,使其不再正确

    希望这是有意义的!我们整天都在关注这个问题


    谢谢!

    我遇到的情况略有不同;在横向模式下,
    UIViewController
    子类从上到下而不是从左到右交换

    对我有效的修复方法是将所有视图添加到一个“内部”视图中,然后翻转该视图,而不是
    UIViewController
    的正常
    视图

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                               forView:[self innerView]
                                 cache:YES];
    

    其中
    [self-innerView]
    [self-view]
    的唯一子视图,所有子视图都在其中。

    RootViewController的超类是什么?它只是一个普通的UIViewController吗?是的,只是一个UIViewController。我没有使用任何导航或选项卡栏。
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                               forView:[self innerView]
                                 cache:YES];