gpt4 book ai didi

ios - 具有透明背景的模态 UISplitViewController

转载 作者:行者123 更新时间:2023-11-28 16:08:50 27 4
gpt4 key购买 nike

我需要模态呈现一个 UISplitViewController(在 iPhone 和 iPad 上),它应该有一个透明的背景(我将添加模糊 View )。我在呈现 UIViewController 时能够做到这一点,但它不适用于 Split View Controller 。我的 Split View Controller 有 2 个导航 Controller 。

我的结果是主视图 Controller 有黑色背景。

感谢您的帮助。

最佳答案

您的 UISplitViewController 是 Root View Controller 吗?如果没有,它会表现出奇怪的行为。每个苹果:

Note

"...Although it is possible to install a split view controller as a child in some other container view controllers, doing is not recommended in most cases. Split view controllers are normally installed at the root of your app’s window. ..."

我用过这个(从细节 View Controller 调用,使用带有两个导航 Controller 的 Split View Controller 。)此时我想重置导航堆栈:

let firstVC = self.storyboard?.instantiateViewController(withIdentifier: "FirstViewController") as! FirstViewController
let secondVC = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
// Get a reference the the Master View nav controller
let masterNav = self.splitViewController!.viewControllers[0] as! UINavigationController
// Set desired VC's as nav stack RootViewControllers
self.navigationController?.setViewControllers([matchVC], animated: true)
masterNav.setViewControllers([masterMatchTableView], animated: true)

如果您想维护导航堆栈,您可以在两个导航 Controller 上调用 .pushViewController

如果您仍在处理此问题,请发布一些代码,我很乐意查看。

编辑:

因此,您无法模态呈现 Split View Controller : https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/SplitViewControllers.html

A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window. The panes of your split view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface. Split view controllers cannot be presented modally.

我在上面发布的代码片段将同时显示主视图和详细 View 。或者,您可以呈现一个新的 VC 作为详细 View ,并设置 UISplitViewController.preferredDisplayMode = .primaryHidden 以模态呈现单个 VC。

关于ios - 具有透明背景的模态 UISplitViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39855992/

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