gpt4 book ai didi

ios - UINAvigationController -> setViewControllers 导致崩溃

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

我遇到了一个非常奇怪的情况 - 调用 method UINAvigationController -> setViewControllers:animated: 导致应用程序崩溃。仅在 iOS 10.3.2 上以及当我在 Release模式下构建应用程序时才会出现这种情况。

我收集了更多详细信息。希望他们能帮助理解发生的事情。

此问题仅出现在 iOS 10.3.2 和 Release模式下。我在 iPhone 10.3.2 上检查过这一点,发布版本失败,但调试工作正常。另外,我在iOS 10.3.2上的AppStore上检查了该应用程序的以前版本,也没有问题。调试和发布版本在所有以前版本的 iOS 上都可以正常工作。

AppStore 中的先前版本是使用旧版本的 Xcode 构建的,现在我使用最新的 Xcode 8.3.2。我猜是系统问题,与iOS和Xcode版本有关。

关于来源,看起来像:

AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
...
window = UIWindow(frame: UIScreen.main.bounds)
....
let navigationController = UINavigationController(rootViewController: viewController)
window.rootViewController = navigationController
window.makeKeyAndVisible()
}

ViewController.swift

override func viewDidLoad() {
super.viewDidLoad()
...
continueButton.addTarget(self, action: #selector(navigateForward), for: .touchUpInside)
...
}

func navigateForward(sender: UIButton!) {
let nextController = FinalBuilder.viewController()
navigationController?.setViewControllers([nextController], animated: true)
}

我之前说过,除了一种情况外,它在所有情况下都可以正常工作:)。 UINAvigationController -> setViewControllers:animated: 是标准的 iOS 方法,从 iOS 3.0+ 开始可用,现在不推荐使用。没有黑客或其他东西可以破坏程序流程。这是通常的使用方式。

附注我没有可以向您提供调试日志或任何其他消息,因为该应用程序只是从屏幕上消失,根本没有任何通知。

最佳答案

如果它不起作用,那么你可以尝试简单的方法,例如

简单创建 View Controller 对象并传入导航

let nextVC = storyboard?.instantiateViewController(withIdentifier:"ScrollViewController") as! ScrollViewController
self.navigationController?.pushViewController(nextVC, animated: true)

关于ios - UINAvigationController -> setViewControllers 导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44196516/

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