我在這裏一個非常奇怪的情況 - 的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