UINavigation 将同一个视图控制器推送两次错误
UINavigation is pushing the same view controller twice error
将视图控制器推入堆栈时出现以下错误:
Thread 1: Exception: "<UINavigationController: 0x7f9345817a00> is pushing the same view controller instance (<xxxx.HelpViewController: 0x7f9346143390>) more than once which is not supported and is most likely an error in the application : com.xxx.xxx1"
我正在使用以下代码从 table 视图控制器调用视图控制器:
let myVC = self.storyboard?.instantiateViewController(identifier: "HelpViewController") as! HelpViewController
// pass any parms here
myVC.stringPassed = label!.text!
navigationController?.pushViewController(myVC, animated: true)
self.navigationController!.pushViewController(myVC, animated: false)
我只有一个视图控制器副本,这是我第一次将此视图压入堆栈。
如有任何帮助,我们将不胜感激。
这是日志:
2020-08-13 17:42:45.289742-0500 NCLEX[29470:2944371] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '<UINavigationController: 0x7f94e980ce00> is pushing the same view controller instance (<xxx.HelpViewController: 0x7f94e54634a0>) more than once which is not supported and is most likely an error in the application : com.xxx.xxx'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23e3de6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff512539b2 objc_exception_throw + 48
2 UIKitCore 0x00007fff48be2df6 -[UINavigationController pushViewController:transition:forceImmediate:] + 451
3 UIKitCore 0x00007fff48be2a9f -[UINavigationController pushViewController:animated:] + 669
4 UIKitCore 0x00007fff48ca880d -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 294
5 UIKitCore 0x00007fff48ca495b -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 126
6 UIKitCore 0x00007fff48ca46cf -[_UIViewControllerTransitionContext completeTransition:] + 106
7 UIKitCore 0x00007fff48cb6e1f __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.158 + 806
8 UIKitCore 0x00007fff4982093c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 671
9 UIKitCore 0x00007fff497f15c9 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 220
10 UIKitCore 0x00007fff497f1bc0 -[UIViewAnimationState animationDidStop:finished:] + 276
11 UIKitCore 0x00007fff497f1d46 -[UIViewAnimationState animationDidStop:finished:] + 666
12 QuartzCore 0x00007fff2b4fbadc _ZN2CA5Layer23run_animation_callbacksEPv + 306
13 libdispatch.dylib 0x0000000110475e8e _dispatch_client_callout + 8
14 libdispatch.dylib 0x0000000110483d97 _dispatch_main_queue_callback_4CF + 1149
15 CoreFoundation 0x00007fff23da1869 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
16 CoreFoundation 0x00007fff23d9c3b9 __CFRunLoopRun + 2041
17 CoreFoundation 0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
18 GraphicsServices 0x00007fff38c39bbe GSEventRunModal + 139
19 UIKitCore 0x00007fff49325968 UIApplicationMain + 1605
20 NCLEX 0x000000010f37007b main + 75
21 libdyld.dylib 0x00007fff520ce1fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
如果您不需要动画,您需要评论这 2 行中的 1 行(主要是第二行)
navigationController?.pushViewController(myVC, animated: true)
self.navigationController!.pushViewController(myVC, animated: false)
因为他们做同样的事情,即推动相同的 vc 两次导致崩溃
将视图控制器推入堆栈时出现以下错误:
Thread 1: Exception: "<UINavigationController: 0x7f9345817a00> is pushing the same view controller instance (<xxxx.HelpViewController: 0x7f9346143390>) more than once which is not supported and is most likely an error in the application : com.xxx.xxx1"
我正在使用以下代码从 table 视图控制器调用视图控制器:
let myVC = self.storyboard?.instantiateViewController(identifier: "HelpViewController") as! HelpViewController
// pass any parms here
myVC.stringPassed = label!.text!
navigationController?.pushViewController(myVC, animated: true)
self.navigationController!.pushViewController(myVC, animated: false)
我只有一个视图控制器副本,这是我第一次将此视图压入堆栈。
如有任何帮助,我们将不胜感激。
这是日志:
2020-08-13 17:42:45.289742-0500 NCLEX[29470:2944371] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '<UINavigationController: 0x7f94e980ce00> is pushing the same view controller instance (<xxx.HelpViewController: 0x7f94e54634a0>) more than once which is not supported and is most likely an error in the application : com.xxx.xxx'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23e3de6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff512539b2 objc_exception_throw + 48
2 UIKitCore 0x00007fff48be2df6 -[UINavigationController pushViewController:transition:forceImmediate:] + 451
3 UIKitCore 0x00007fff48be2a9f -[UINavigationController pushViewController:animated:] + 669
4 UIKitCore 0x00007fff48ca880d -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 294
5 UIKitCore 0x00007fff48ca495b -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 126
6 UIKitCore 0x00007fff48ca46cf -[_UIViewControllerTransitionContext completeTransition:] + 106
7 UIKitCore 0x00007fff48cb6e1f __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.158 + 806
8 UIKitCore 0x00007fff4982093c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 671
9 UIKitCore 0x00007fff497f15c9 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 220
10 UIKitCore 0x00007fff497f1bc0 -[UIViewAnimationState animationDidStop:finished:] + 276
11 UIKitCore 0x00007fff497f1d46 -[UIViewAnimationState animationDidStop:finished:] + 666
12 QuartzCore 0x00007fff2b4fbadc _ZN2CA5Layer23run_animation_callbacksEPv + 306
13 libdispatch.dylib 0x0000000110475e8e _dispatch_client_callout + 8
14 libdispatch.dylib 0x0000000110483d97 _dispatch_main_queue_callback_4CF + 1149
15 CoreFoundation 0x00007fff23da1869 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
16 CoreFoundation 0x00007fff23d9c3b9 __CFRunLoopRun + 2041
17 CoreFoundation 0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
18 GraphicsServices 0x00007fff38c39bbe GSEventRunModal + 139
19 UIKitCore 0x00007fff49325968 UIApplicationMain + 1605
20 NCLEX 0x000000010f37007b main + 75
21 libdyld.dylib 0x00007fff520ce1fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
如果您不需要动画,您需要评论这 2 行中的 1 行(主要是第二行)
navigationController?.pushViewController(myVC, animated: true)
self.navigationController!.pushViewController(myVC, animated: false)
因为他们做同样的事情,即推动相同的 vc 两次导致崩溃