UISplitViewController以纵向显示上面的详细主视图 [英] UISplitViewController display master view above detail in portrait orientation

查看:98
本文介绍了UISplitViewController以纵向显示上面的详细主视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UINavigationController中嵌入了一个UISplitViewController,它带有一个UINavigationItem按钮,可以纵向切换主视图的显示。我想在纵向首次加载纵向时显示详细视图上方的主视图。

I have a UISplitViewController embedded in a UINavigationController with a UINavigationItem button to toggle the display of the master view in portrait orientation. I want to show the master view above the detail view when the view first loads in portrait orientation.

我发现的任何类似示例都显示了纵向分割屏幕的主视图和详细视图,但我需要将详细视图全屏显示为主视图首次加载UISplitViewController时覆盖详细视图(就好像主视图已从左侧滑出)。有谁知道怎么做?

Any similar examples I have found show the master and detail views splitting the screen in portrait orientation, but I need the detail view to be full screen in portrait with the master view covering the detail view when the UISplitViewController first loads (as if the master view has been swiped out from the left). Does anyone know how to do that?

推荐答案

编辑:这不是重复的。在评论中发现的答案。解决方案是在UISplitViewController上使用 preferredDisplayMode 并将其设置为 UISplitViewControllerDisplayModePrimaryOverlay

Edit: It's not a duplicate. Answer discovered in the comments. The solution is to use preferredDisplayMode on UISplitViewController and setting it to UISplitViewControllerDisplayModePrimaryOverlay

将上下文的原始答案留给评论和后代。

Left the original answer for context to the comments and posterity.

原始答案

这与此重复: UISplitViewController在iPhone上的纵向显示详细信息VC而不是主屏幕

作为参考,解决方案在case是让视图控制器实现 UISplitViewControllerDelegate 使用以下代码:

For reference, the solution in that case was to have the view controller that implements UISplitViewControllerDelegate use the following code:

- (BOOL)splitViewController:(UISplitViewController *)splitViewController
collapseSecondaryViewController:(UIViewController *)secondaryViewController
  ontoPrimaryViewController:(UIViewController *)primaryViewController {

    if ([secondaryViewController isKindOfClass:[UINavigationController class]]
        && [[(UINavigationController *)secondaryViewController topViewController] isKindOfClass:[DetailViewController class]]
        && ([(DetailViewController *)[(UINavigationController *)secondaryViewController topViewController] detailItem] == nil)) {

        // Return YES to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
        return YES;

    } else {

        return NO;

    }
}

这篇关于UISplitViewController以纵向显示上面的详细主视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆