gpt4 book ai didi

ios - 标签栏内的 UISplitViewController

转载 作者:IT王子 更新时间:2023-10-29 08:08:15 24 4
gpt4 key购买 nike

我有一个有登录屏幕的应用程序,当用户登录时,会推送一个标签栏 Controller 。我目前有一些观点会受益于苹果现在允许在所有 iOS 设备中使用 Split View Controller 这一事实,所以当我读到 UISplitViewController 必须始终是 Root View Controller 时,我正准备实现这一点。所以我想知道是否可以使用 UISplitViewController 使其中一个选项卡中的 View 成为主从 View ,或者我需要手动实现吗?

如果无法将 Split View显示为选项卡,是否可以从选项卡栏 Controller 中推送? (例如,用户点击表格 View 中的一行,然后出现主从 View )。

最佳答案

iOS 14 中的

UISplitViewController 获得了新的 API,包括一种新的列样式,其行为不同于“经典”界面的 unspecified 样式。使用现代列式 API,如果您尝试将 UISplitViewController 嵌入到 UITabBarController 中,它可能不会像您预期的那样运行。例如,至少从 iOS 15 开始,当您希望并排显示主要和次要 View Controller 时,可能只有次要 View Controller 可见。 documentation确实注意到以下几点:

When you build your app’s user interface, the split view controller is typically the root view controller of your app’s window. ... Although it’s possible to install a split view controller as a child in some other container view controllers, doing so is not recommended in most cases.

然而,我已经发布了多个应用程序,这些应用程序使用经典 API(通过 Storyboard和编程方式)将 Split View Controller 放入选项卡栏 Controller 中,并且它们从 iOS 15 开始继续工作。但是远离它可能是明智的这是因为它似乎不是官方支持的配置。

iOS 14 之前的原始答案:

您绝对可以在 UITabBarController 中嵌入 UISplitViewController。我已经为我在 App Store 上发布的应用程序完成了该操作。它有 3 个选项卡,每个选项卡都是一个 Split View Controller 。

只需将标签栏 Controller 拖出到 Storyboard中,删除它添加的两个 Controller ,然后拖出一个 Split View Controller 。控制从选项卡栏 Controller 拖动到 Split View Controller 并选择“ View Controller ”关系 segue。

在低于 Xcode 8 的 Xcode 版本中,您可能会在 Interface Builder Canvas 中的 Split View Controller 的顶部和底部看到黑色或白色条,但当应用程序在设备上运行时,这些不会出现。

enter image description here

这是运行的应用程序,用于显示嵌入在 iPhone 6s Plus 标签栏 Controller 中的 Split View:

enter image description here

关于ios - 标签栏内的 UISplitViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27325369/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com