Segue does not work with iOS6

Sorry if my question may seem silly to some of you. I'm relatively new to iOS Development, but I need to port the app for iOS6. The app works fine on iOS 5 and Xcode 4.3.2, but I have a weird bug with Xcode 4.5 on the iPhone 6.0 simulator. After loading the initial screen, I can press any button that I want, and I get an error message:

 `Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'register'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.`

The prepareForSegue method for StartScreenViewController is as follows:

if ([[segue identifier] isEqualToString:@"register"] || [[segue identifier] isEqualToString:@"forgotPassword"]) {
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:[segue destinationViewController]];
    appDelegate.window.rootViewController = navController;
}

Setting a breakpoint shows me that the method is still called corectly, but after the ForSegue preparation is complete, the application crashes with the above error. Can someone point me in the right direction?

Thank you very much martin

+5
3

push segue Cocoa, StartScreenViewController.

  • , .
  • , .

prepareForSegue: VC, iOS. VC, , , , window.rootViewController.

: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html

+5

, " ", , , , , , . ; . , , segue - , , .

. iOS ( ), , , . :

http://www.apeth.com/iOSBook/ch19.html

+5

. ios6, , , . .

:

NavigationControllerUIViewController ( PageControl, , ) → UITableViewController ( ), , DetailsViewController ( UIViewController).

prepareForSegue:

    if ([[segue identifier] isEqualToString:@"ShowTelegrafDetails"]){
    TelegrafDetailsViewController *details = (TelegrafDetailsViewController*)segue.destinationViewController;

    NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];     

    if([self isItPad])
        details.linkFromTableView = [[otherNews objectAtIndex:myIndexPath.row] link];
    else
        details.linkFromTableView = [[[myViewController.itemMatrix objectAtIndex:[self calculateCurrentPage]] objectAtIndex:myIndexPath.row] link];

    NSLog(@"%@",segue.sourceViewController);
    NSLog(@"%@",segue.destinationViewController);

    [self.myViewController.navigationController pushViewController:details animated:YES];
    }

, , , , NavigationController . , RootViewController - , AppDelegate, , root (UITableViewController).

- - , , . , , .

, - , , .: D

Thanx .

EDIT:

I managed to solve this problem. Just remove the segues and put the code from prepareForSegue in didSelectRowAtIndexPath with the corresponding fixes. This is not an ideal solution, but fixes the problem. Although, I have plans to support 4.3+ devices, and storyboards in this case are not an option.

In addition, I double-checked the code, found out that the RootViewController is correctly created and displayed, the NavigationController works well, and I still can not understand why segues do not work.

Greetings.

+2
source

All Articles