gpt4 book ai didi

ios - 检测我的 Controller 是否显示为弹出窗口

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

使用 Xcode 10.1 和 Swift 4.2.1,iOS 12

我在导航 Controller 中嵌入了一个表格 View 。在右上角有一个条形按钮和一个从该按钮到保存静态表格 View 的导航 Controller 的转场(弹出框),这里的单元格进一步转场到其他表格 View 。

在 iPhone 上,静态表格 View 显示为全屏模式,在 iPad 上,它是一个弹出窗口,到目前为止还可以。我已经在 Storyboard 中设置了所有内容,不知道这是否是原因,但现在我正在努力检查 View 是弹出窗口还是全屏模式。

我试过:

print("\(presentationController)")
if presentationController is UIPopoverPresentationController {
// Do something
}

但这不起作用 -> print("\(presentationController)")给我Optional(<_UIFullscreenPresentationController: 0x7fd00ad45770>)在 iPhone 和 iPad 上。

我也尝试过:

if popoverPresentationController != nil {
print("popover")
}

但如果在 iPhone 或 iPad 上启动,则会打印弹出窗口。

我是不是做错了什么,还是遗漏了什么?

最佳答案

目前我正在使用这个:

if (popoverPresentationController?.arrowDirection != UIPopoverArrowDirection.unknown) {
tableView.sectionHeaderHeight = CGFloat.leastNormalMagnitude
tableView.sectionFooterHeight = CGFloat.leastNormalMagnitude
}

这很简单,而且很有效。如果有人真的有可能发现“if is a popover”,非常欢迎您将其张贴在这里。

关于ios - 检测我的 Controller 是否显示为弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55354899/

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