ios - 推送 segue 的问题

标签 ios objective-c

我分配了一个按钮来将 segue 推送到另一个 View Controller ,但是当我执行这部分代码时,我得到以下信息:

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]));

不确定是什么问题?

建议和想法?

最佳答案

您正在尝试从 UIViewController 推送未嵌入 UINavigationController .

你需要做的是去你的 Storyboard,选择UIViewController您尝试从中推送,请转到 Editor菜单,选择 Embed in , 和 Navigation Controller .然后可以推送其他UIViewControllers在上面。

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

关于ios - 推送 segue 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21914394/

相关文章:

ios - Tableview单元格可重用性,剪切标签文本

java - 用户登录后,我应该使用类实例(序列化)还是单例来存储 userInfo

iOS 如何用另一种语言显示日期,

ios - 动画 UIButton 向下 - Xcode

IOS/Objective-C。在离开 View Controller 之前检测选项卡栏上选项卡的按下

objective-c - 当每个线程都可以处理与其他线程中的数据无关的数据时,是否可以在线程之间重用一个共享的托管对象上下文?

objective-c - 编程更改界面方向,但键盘方向与 iOS 8 上的状态栏不同

ios - 文件在 iTunes 中不显示文件共享

objective-c - 在 swift3.2/4 中正确解除分配 MTAudioProcessingTapRef

ios - 从 UIImagePickerController 获取 UIImage 的 URL