Search code examples
iphoneiosios6

Trouble with push segue in iOS 6 on iPhone storyboard


I have a CalculatorViewController with a button called Graph. Clicking Graph causes a push segue to my CalculaterGraphViewController but instead it crashes when I push it.

My prepare to segue is set in CalculatorViewController.m as:

- (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 
    }   
}

After crashing I get this in my output:

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)


Solution

  • You need Navigation controller in order to use Push Segue!

    A "push" style segue can only be done from a view controller that is being managed by a UINavigationController.