gpt4 book ai didi

ios - 将 displayModeButtonItem 用于我自己的 UIButton SWIFT

转载 作者:行者123 更新时间:2023-11-29 02:21:08 24 4
gpt4 key购买 nike

我的应用程序使用 splitViewcontroller。我删除了 DetailViewController 的导航栏。所以我不能使用:

navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem()
navigationItem.leftItemsSupplementBackButton = true

但我需要自己的按钮来在弹出窗口中显示我的 MasterViewController,就像 leftBarButtonItem 完成的那样。

我试过了:

@IBAction func showAll() {
rootViewController.splitViewController?.displayModeButtonItem().action
}

但它不起作用。

编辑:

我试图在我的 masterViewController 中添加我自己的弹出窗口。

@IBAction func showAll(sender : UIButton!) {

let popover = UIPopoverController(contentViewController:masterViewController)
popover.presentPopoverFromRect(sender.frame, inView: self.view, permittedArrowDirections:UIPopoverArrowDirection(), animated: true)
}

但是应用程序崩溃了:

Application tried to present modally an active controller <DetailViewController: 0x7f8393d96540>

我不明白,因为我需要在detailViewController的 View 中显示popover。否则我该怎么办?

最佳答案

它与@pbasdf 解决方案完美配合:

@IBAction func showAll() {
self.splitViewController?.preferredDisplayMode = .PrimaryOverlay
self.splitViewController?.displayModeButtonItem().action
}

关于ios - 将 displayModeButtonItem 用于我自己的 UIButton SWIFT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28117978/

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