1

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)

4

2 回答 2

3

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.

于 2013-07-02T01:35:31.137 回答
0

From what I can tell it lays it out for you right in your crash log--You need to nest your CalculatorViewController within a UINavigationController.

Drag one out from the elements box in Interface Builder (or search for it by pressing Control-Cmd-Alt-3, and type UINavigationController). Set CalculatorViewController to be the UIViewController connected to the UINavigationController by control dragging from the UINavigationController and selecting the Relationship Segue as the root view controller.

于 2013-07-02T01:37:42.660 回答