Ios UINAvigationController->;SetViewController导致崩溃
我有一个非常奇怪的情况-调用Ios UINAvigationController->;SetViewController导致崩溃,ios,swift,uinavigationcontroller,rx-swift,rx-cocoa,Ios,Swift,Uinavigationcontroller,Rx Swift,Rx Cocoa,我有一个非常奇怪的情况-调用UINAvigationController->setViewControllers:animated:会导致应用程序崩溃。只有在iOS 10.3.2上,以及在发布模式下构建应用程序时,才会出现这种情况 我收集了更多的细节。希望他们能帮助理解发生了什么 该问题出现在iOS 10.3.2上,仅在发布模式下出现。我已经用10.3.2在iPhone上检查了这一点,发布版本失败,但调试正常。此外,我已经在iOS 10.3.2上的AppStore上检查了应用程序的早期版本,它也
UINAvigationController->setViewControllers:animated:
会导致应用程序崩溃。只有在iOS 10.3.2上,以及在发布模式下构建应用程序时,才会出现这种情况
我收集了更多的细节。希望他们能帮助理解发生了什么
该问题出现在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+上获得,现在不再推荐。没有黑客或其他可能破坏程序流的东西。这是通常的使用方法
另外,没有调试日志或任何其他消息,我可以提供给你,因为应用程序只是从屏幕上消失,没有任何通知。如果它不工作,那么你可以尝试像这样简单的方法 简单创建视图控制器对象并传入导航
let nextVC = storyboard?.instantiateViewController(withIdentifier:"ScrollViewController") as! ScrollViewController
self.navigationController?.pushViewController(nextVC, animated: true)
我发现这种行为是在RxCocoa从3.3.1更新到3.4.0之后出现的。发生这种情况的原因是,
DelegateProxyType.swift:extension ObservableType:func subscribeProxyDataSource
:
return Disposables.create { [weak object] in
subscription.dispose()
- unregisterDelegate.dispose()
object?.layoutIfNeeded()
+ unregisterDelegate.dispose()
}
我已将报告发布到存储库。如果您感兴趣,可以在此处检查最终状态。是否可以粘贴准确的崩溃错误消息?没有错误消息。我在描述中提到过。那么您是如何知道
setViewControllers
导致崩溃的呢?因为没有这个调用就不会发生崩溃:)。如果改用pushViewController方法,效果很好。总之,我找到了问题的真正原因。谢谢你的评论。