我在这里一个非常奇怪的情况 - 的methodUINAvigationController -> setViewControllers:animated:
调用导致应用程序崩溃。它只在iOS 10.3.2上开发,当我在发布模式下构建应用程序。的UINavigationController - > setViewControllers导致系统崩溃
我收集了更多的细节。希望他们能帮助理解发生的事情。
该问题仅出现在iOS 10.3.2和发布模式中。我用10.3.2在iPhone上检查过这一点,发布版本失败,但调试工作正常。另外,我已经在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+获得,现在不推荐使用。没有任何黑客或其他什么东西可以破坏程序流程。这是通常的使用方法。
P.S.没有调试日志或任何其他消息,我可以提供给你,因为应用程序只是从屏幕上消失,根本没有通知。
你能粘贴确切的崩溃错误信息吗? – user1046037
没有错误消息。我在描述中提到过它。 – comrade
那你是怎么知道'setViewControllers'导致崩溃的? – user1046037