来自模态视图控制器的segue错误(平放和常规)

时间:2018-12-29 06:32:12

标签: swift segue

我有一个具有以下导航的应用: (导航控制器)->初始屏幕->主屏幕-> Modal VC1-> Modal VC2(当用户登录时)。当用户未登录时,它进入Splash屏幕->入职屏幕。

Modal VC2具有注销按钮,我想在其中退出到初始屏幕。

我尝试了unwind方法来尝试解开到第一个根控制器:

self.performSegue(withIdentifier: "unwindSegueToSplash", sender: nil)

并且我确保在正确的文件中具有正确的标识符和正确的IBAction展开:

(一旦我获得足够的声誉,就会使用照片对此进行更新)

但出现此错误(它说它不能识别标识符):

2018-12-28 21:56:22.171802-0800 test[23398:2685262] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<test.LogOutViewController: 0x7ff5ce6189c0>) has no segue with identifier 'unwindSegueToSplash''
*** First throw call stack:
(
0   CoreFoundation                      0x000000010ec3c1bb __exceptionPreprocess + 331
1   libobjc.A.dylib                     0x000000010e1da735 objc_exception_throw + 48
2   UIKitCore                           0x0000000113317568 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3   test                                0x000000010bc6f944 $S5test20LogOutViewControllerC03logC0yyypSgF + 580
4   test                                0x000000010bc6fa2c $S5test20LogOutViewControllerC03logC0yyypSgFTo + 188
5   UIKitCore                           0x0000000113934ecb -[UIApplication sendAction:to:from:forEvent:] + 83
6   UIKitCore                           0x00000001133700bd -[UIControl sendAction:to:forEvent:] + 67
7   UIKitCore                           0x00000001133703da -[UIControl _sendActionsForEvents:withEvent:] + 450
8   UIKitCore                           0x000000011336f31e -[UIControl touchesEnded:withEvent:] + 583
9   UIKitCore                           0x00000001139700a4 -[UIWindow _sendTouchesForEvent:] + 2729
10  UIKitCore                           0x00000001139717a0 -[UIWindow sendEvent:] + 4080
11  UIKitCore                           0x000000011394f394 -[UIApplication sendEvent:] + 352
12  UIKitCore                           0x0000000113a245a9 __dispatchPreprocessedEventFromEventQueue + 3054
13  UIKitCore                           0x0000000113a271cb __handleEventQueueInternal + 5948
14  CoreFoundation                      0x000000010eba1721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15  CoreFoundation                      0x000000010eba1054 __CFRunLoopDoSources0 + 436
16  CoreFoundation                      0x000000010eb9b63f __CFRunLoopRun + 1263
17  CoreFoundation                      0x000000010eb9ae11 CFRunLoopRunSpecific + 625
18  GraphicsServices                    0x000000011753a1dd GSEventRunModal + 62
19  UIKitCore                           0x000000011393381d UIApplicationMain + 140
20  test                                0x000000010bc6c077 main + 71
21  libdyld.dylib                       0x0000000110ca2575 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

当我对应用程序中的其他页面进行常规搜索时,也会遇到同样的错误,而不仅仅是放松。我确保这些脚本在情节提要部分中正确书写了它们的标识符。

我还尝试了其他方法,这些方法在弹出到根视图控制器的地方都可以看到,但是看来我的根视图控制器是主屏幕,而不是启动屏幕(我假设这与他们是模态视图控制器?)。它确实在这里正确无误。

self.navigationController?.popToRootViewController(animated: true)

UIApplication.shared.keyWindow?.rootViewController?.navigationController?.popToRootViewController(animated: true)

我不想呼叫2个segues来进入启动屏幕,因为我想直接退回到启动屏幕,而用户之间看不到任何东西,我该怎么做?

0 个答案:

没有答案
相关问题