ios - 崩溃:应用程序试图在其自身上呈现模态视图 Controller 。呈现 Controller 是 UISearchController

标签 ios crash presentmodalviewcontroller

我在 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/

相关文章:

ios - 关闭 modalviewwontroller 后 Viewwillappear 不会被调用

variables - Octave 崩溃后不要尝试保存变量

ios - 用手指向上拖动 Child View Controller 并在点后锁定

ios - 通过单击按钮切换 View Controller 会导致以 NSException 类型的未捕获异常终止

iphone - 是否可以在不创建虚拟行的情况下更改 UITableView 中占位符行的高度?

ios - 使用 Firebase 数据库、Swift 3 防止重复用户

ipad - UIViewControllerHierarchyInconsistency 在 iPad 方向 iOS 6.1.3 期间发生

javascript - 从网络应用程序调用 FB.login() 时,官方 Facebook iOS 应用程序总是崩溃

IOS:打开和关闭一些 View Controller

objective-c - GKLeaderboardViewController 初始排行榜