gpt4 book ai didi

ios - 在自己的窗口中显示 UIAlertController 时出现 NSException

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

我试图在 UISplitViewController 上显示 UIAlertController。我已经尝试了在此网站上找到的所有内容,并且坚持使用此处找到的扩展。

扩展 UIAlertController {

func presentInOwnWindow(animated: Bool, completion: (() -> Void)?) {
let alertWindow = UIWindow(frame: UIScreen.main.bounds)
alertWindow.rootViewController = UIViewController()
alertWindow.windowLevel = UIWindowLevelAlert + 1;
alertWindow.makeKeyAndVisible()
alertWindow.rootViewController?.present(self, animated: animated, completion: completion)
}

我在执行 Present 后立即收到异常,并且看不到堆栈跟踪,并且未触发异常断点。

libc++abi.dylib:以 NSException 类型的未捕获异常终止

它在 UISplitViewController 折叠的手机上呈现良好。我错过了什么?

最佳答案

潜在问题是UIWindowLevelAlert + 1;。尝试使用 UIWindowLevelNormal 代替。新窗口将放置在默认窗口上方。以及上面的 UISplitViewController

func presentInOwnWindow(animated: Bool, completion: (() -> Void)?) {
let alertWindow = UIWindow(frame: UIScreen.main.bounds)
alertWindow.rootViewController = UIViewController()
alertWindow.windowLevel = UIWindowLevelNormal;
alertWindow.makeKeyAndVisible()
alertWindow.rootViewController?.present(self, animated: animated, completion: completion)
}

关于ios - 在自己的窗口中显示 UIAlertController 时出现 NSException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47228651/

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