推送segue的问题

时间:2014-02-20 16:52:08

标签: ios objective-c

我指定了一个按钮将segue推送到另一个视图控制器但是当我执行这部分代码时,我得到以下内容:

2014-02-20 10:44:29.357 nar[20244:70b] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
*** First throw call stack:
(
    0   CoreFoundation                      0x017395e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014bc8b6 objc_exception_throw + 44
    2   UIKit                               0x0076eca5 -[UIStoryboardPushSegue destinationContainmentContext] + 0
    3   UIKit                               0x0075f07e -[UIStoryboardSegueTemplate _perform:] + 174
    4   UIKit                               0x0075f0f9 -[UIStoryboardSegueTemplate perform:] + 115
    5   libobjc.A.dylib                     0x014ce874 -[NSObject performSelector:withObject:withObject:] + 77
    6   UIKit                               0x0022c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
    7   UIKit                               0x0022c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    8   UIKit                               0x003240c1 -[UIControl sendAction:to:forEvent:] + 66
    9   UIKit                               0x00324484 -[UIControl _sendActionsForEvents:withEvent:] + 577
    10  UIKit                               0x00323733 -[UIControl touchesEnded:withEvent:] + 641
    11  UIKit                               0x0059ec7f _UIGestureRecognizerUpdate + 7166
    12  UIKit                               0x0026919a -[UIWindow _sendGesturesForEvent:] + 1291
    13  UIKit                               0x0026a0ba -[UIWindow sendEvent:] + 1030
    14  UIKit                               0x0023de86 -[UIApplication sendEvent:] + 242
    15  UIKit                               0x0022818f _UIApplicationHandleEventQueue + 11421
    16  CoreFoundation                      0x016c283f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    17  CoreFoundation                      0x016c21cb __CFRunLoopDoSources0 + 235
    18  CoreFoundation                      0x016df29e __CFRunLoopRun + 910
    19  CoreFoundation                      0x016deac3 CFRunLoopRunSpecific + 467
    20  CoreFoundation                      0x016de8db CFRunLoopRunInMode + 123
    21  GraphicsServices                    0x036de9e2 GSEventRunModal + 192
    22  GraphicsServices                    0x036de809 GSEventRun + 104
    23  UIKit                               0x0022ad3b UIApplicationMain + 1225
    24  w1nnar                              0x00002f2d main + 141
    25  libdyld.dylib                       0x01d7770d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

我被带到我的主文件main.m,它突出显示以下内容:

    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

不确定是什么问题?

建议和想法?

2 个答案:

答案 0 :(得分:2)

您正试图从UIViewController未加入UINavigationController

您需要做的是转到故事板,选择您要推送的UIViewController,转到Editor菜单,选择Embed in,然后{{1 }}。然后你可以推送其他Navigation Controller

有关iOS应用中导航的信息,请阅读Apple's documentation

答案 1 :(得分:1)

您需要UINavigationController来嵌入当前视图。由于Segues使用导航控制器来推动其他视图控制器。

如果您正在使用故事板,请添加UINavigationController并将视图嵌入其中。