shrimp-hamburger 2013-07-02 02:15 采纳率: 0%
浏览 3466
已采纳

推送segue时ios6崩溃

使用的CalculatorViewController中有一个graph按钮。点击按钮会触发segue推送到CalculaterGraphViewController 。运行之后崩溃了。

CalculatorViewController.m中的代码:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"Show Graphs"])
    {
        // Do we need to set something else up in case it crashes 
    }   
}

崩溃信息输出:

2013-07-01 18:32:13.170 Calculator[1150:c07] * Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'Show Graphs'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.' * First throw call stack: (0x1c95012 0x10d2e7e 0x46cf31 0x45eb99 0x45ec14 0x10e6705 0x1a2c0 0x1a258 0xdb021 0xdb57f 0xda6e8 0x49cef 0x49f02 0x27d4a 0x19698 0x1bf0df9 0x1bf0ad0 0x1c0abf5 0x1c0a962 0x1c3bbb6 0x1c3af44 0x1c3ae1b 0x1bef7e3 0x1bef668 0x16ffc 0x2abd 0x29e5 0x1) libc++abi.dylib: terminate called throwing an exception (lldb)

  • 写回答

2条回答 默认 最新

  • ReyZhang 移动开发领域新星创作者 2013-07-02 02:53
    关注

    出错的原因是,你当前的控制器,并非是直接或问接继承自UINavigationController 。只有在被压入导航控制器栈中的控制器才可以推送(push) 另一个控制器(viewcontroller)

    通过上面的解释,你应该知道了如果要让当前控制器可以有推送push view controller 的功能,需要当前控制器为UINavigationController,但如果不是,也有方法解决,你可以用下面的代码来将当前控制器包装成UINavigationController

    UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:currentController ];
    [nav pushViewController:viewcontroller animation:YES];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料