gpt4 book ai didi

ios - iPhone 8 Plus 的 Swift Popover 不恰本地关闭

转载 作者:行者123 更新时间:2023-11-28 12:04:24 26 4
gpt4 key购买 nike

在 iPhone 8 Plus 上,每次用户触摸 View 内部时弹出 View Controller 都会消失(比如当用户触摸 View Controller 中的按钮时),而当用户触摸 View 外部时(当我们期望的时候)没有任何反应它解雇)。在针对 iPhone 6s 和几台 iPad 进行测试时,该应用的行为符合预期。

弹出窗口是使用以下 Swift 代码以编程方式创建的:

let selectionViewController =  SelectionTableViewController()
selectionViewController.modalPresentationStyle = .popover
selectionViewController.preferredContentSize = CGSize(width: 200, height: 300)

let popoverViewController = selectionViewController.popoverPresentationController
popoverViewController?.permittedArrowDirections = UIPopoverArrowDirection.up
popoverViewController?.delegate = self
popoverViewController?.sourceView = self.titleView
popoverViewController?.sourceRect = self.titleView.bounds

self.present(selectionViewController, animated: true, completion: nil)

此外,调整自适应呈现样式以在 iPhone 和 iPad 上保持一致的行为:

func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return .none
}

编辑:我已经添加了一个简化版本的应用程序,它在 github 上重现了这个问题: https://github.com/Brandogs/PopoverIssue

最佳答案

事实证明,这个特定的模拟器刚刚被冲洗干净。我在评论中推荐了这个:

Try actually deleting this simulator and creating a whole new simulator. In fact, I frequently delete all simulators and create them anew, and especially after an Xcode update.

OP 做到了这一点,然后应用开始正常运行。

这是一个非常奇怪的问题;我从来没有听说过这样的事情!

关于ios - iPhone 8 Plus 的 Swift Popover 不恰本地关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49696192/

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