gpt4 book ai didi

ios - UISplitViewController 的 preferredDisplayMode : incorrect behavior

转载 作者:可可西里 更新时间:2023-10-31 23:44:45 25 4
gpt4 key购买 nike

我有一个主从应用程序(我使用 Xcode 模板创建它,然后稍微修改了它),我试图设置 UISplitViewController 的 preferredDisplayMode 属性以获得此行为:

UISplitViewControllerDisplayMode.PrimaryOverlay: The primary view controller is layered on top of the secondary view controller, leaving the secondary view controller partially visible.

所以主视图 Controller 最初应该位于详细 View Controller 之上,并且应该可以将其关闭。我在 application:didFinishLaunchingWithOptions: 中更改了这个属性,这是完整的代码:

 
// Inside application:didFinishLaunchingWithOptions:
// Override point for customization after application launch.
let rootViewController = window!.rootViewController as! UINavigationController
// The root view controller is a navigation controller that contains the split view controller
let splitViewController = rootViewController.viewControllers[0] as! UISplitViewController<p></p>

<p>let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
splitViewController.delegate = self</p>

<p>splitViewController.preferredPrimaryColumnWidthFraction = 0.4
splitViewController.maximumPrimaryColumnWidth = 600
<b>splitViewController.preferredDisplayMode = .PrimaryOverlay</b></p>

<p>return true
</p>

I have two problems: first, that's not the behavior that I obtain. The master view controller is hidden when the application launches, and if I click on the left bar button item to show the master, it rapidly appears and then disappears again. If I click it another time it appears without disappearing.
Second, I get a warning in the console:

2015-06-30 12:06:26.613 Presidents[29557:857547] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7b8be610>.

但我的代码中没有转换。

PS:摘自 D. Mark、J. Nutting、K. Topley、F. Olsson、J. LaMarche 所著的“使用 Swift 开始电话开发”一书,第 11 章。

最佳答案

我在我的 iPad 应用程序中使用了它。在主视图 Controller 中:

override func viewDidLoad() {
super.viewDidLoad()

splitViewController?.delegate = self

let rect: CGRect = UIScreen.mainScreen().bounds
if rect.height > rect.width {
// am in portrait: trick to force the master view to open
self.splitViewController?.preferredDisplayMode = .PrimaryOverlay
}

然后:

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.splitViewController?.preferredDisplayMode = .Automatic

现在正在尝试找出如何使用 iPhone 应用程序来实现...编辑:啊,见this previous answer

关于ios - UISplitViewController 的 preferredDisplayMode : incorrect behavior,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31135453/

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