我已经看了好几天了,我不知道发生了什么。
此崩溃每天影响2%的用户(在iPad和iPhone上,不限于iOS 12,底部的完整堆栈跟踪):
Application tried to present modally an active controller <DownloadViewController: 0x10a0c3c00>.
我在代码中的任何地方都没有调用UIViewController presentViewController:animated
,并且没有DownloadViewController
的模式选择。总会有UINavigationController
出现(这是情节提要的初始VC)。
我尝试模拟竞争条件,在该条件下执行两次轮换,或者在其下的UIAlertController
消失后显示UIViewController
并尝试对活动的VC进行轮换,但是我无法重现此崩溃:我能引起的最多是DownloadViewController
被推到UINavigationController
两次(不是世界末日,也没有崩溃)。
在我添加了一些UIAlertController
之后,这种崩溃开始发生了,所以我假设它们与它有关,但是我不知道怎么做。
有什么下一步的想法吗?
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2201b0518 __exceptionPreprocess
1 libobjc.A.dylib 0x21f38b9f8 objc_exception_throw
2 UIKitCore 0x24c01859c -[UIViewController _presentViewController:withAnimationController:completion:]
3 UIKitCore 0x24c01aa7c __63-[UIViewController _presentViewController:animated:completion:]_block_invoke
4 UIKitCore 0x24c033570 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:]
5 UIKitCore 0x24c02f930 -[_UIViewControllerTransitionContext _runAlongsideCompletions]
6 UIKitCore 0x24c02f608 -[_UIViewControllerTransitionContext completeTransition:]
7 UIKitCore 0x24ca2ba00 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:]
8 UIKitCore 0x24ca02758 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
9 UIKitCore 0x24ca02d2c -[UIViewAnimationState animationDidStop:finished:]
10 UIKitCore 0x24ca02dcc -[UIViewAnimationState animationDidStop:finished:]
11 QuartzCore 0x22464f958 CA::Layer::run_animation_callbacks(void*)
12 libdispatch.dylib 0x21fbf17d4 _dispatch_client_callout
13 libdispatch.dylib 0x21fb9f004 _dispatch_main_queue_callback_4CF$VARIANT$mp
14 CoreFoundation 0x220141ec0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
15 CoreFoundation 0x22013cdf8 __CFRunLoopRun
16 CoreFoundation 0x22013c354 CFRunLoopRunSpecific
17 GraphicsServices 0x22233c79c GSEventRunModal
18 UIKitCore 0x24c5afb68 UIApplicationMain
19 WeDownload 0x100ea1f40 main (main.m:14)
20 libdyld.dylib 0x21fc028e0 start
答案 0 :(得分:1)
解决了。问题是在这样的块中:
[UIView transitionWithView:self.view duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
...我实际上已经连续连续两次调用[self presentViewController:alert animated:YES completion:nil];
(其中警报是UIAlertController)。
最重要的学习内容:在错误消息Application tried to present modally an active controller <DownloadViewController: 0x10a0c3c00>
中,DownloadViewController是 presenter 而不是要呈现的东西。如果我能正确理解该错误消息,我会早几天弄清楚的。