我在 fabirc 上遇到了 3 次崩溃。致命异常:NSInvalidArgumentException 应用程序尝试在其自身上呈现模态视图 Controller 。呈现 Controller 是。
0 CoreFoundation __exceptionPreprocess
1 libobjc.A.dylib objc_exception_throw
2 UIKitCore __78-[UIViewController _presentViewController:withAnimationController:completion:]_block_invoke
3 UIKitCore __63-[UIViewController _presentViewController:animated:completion:]_block_invoke_2
4 UIKitCore +[UIView(Animation) performWithoutAnimation:]
5 UIKitCore __63-[UIViewController _presentViewController:animated:completion:]_block_invoke
6 UIKitCore -[UIViewController _performCoordinatedPresentOrDismiss:animated:]
7 UIKitCore -[UIViewController _presentViewController:animated:completion:]
8 UIKitCore -[UIViewController presentViewController:animated:completion:]
9 UIKitCore __51-[UISearchController _performAutomaticPresentation]_block_invoke
10 UIKitCore -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:]
11 UIKitCore -[_UIViewControllerTransitionContext _runAlongsideCompletions]
12 UIKitCore -[_UIViewControllerTransitionContext completeTransition:]
13 UIKitCore -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]
14 UIKitCore __56-[UIPresentationController runTransitionForCurrentState]_block_invoke
15 UIKitCore +[UIViewController _scheduleTransition:]
16 UIKitCore -[UIPresentationController runTransitionForCurrentState]
17 UIKitCore -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:]
18 UIKitCore __99-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]_block_invoke_2
19 UIKitCore +[UIView(Animation) performWithoutAnimation:]
最佳答案
if (!viewControllerToPresent.isBeingPresented) {
//present the view controller
} else {
//if you present viewControllerToPresent at this place then the app will
//crash
}
关于ios - 崩溃:应用程序试图在其自身上呈现模态视图 Controller 。呈现 Controller 是 UISearchController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57936736/