Toby Cronin
Toby Cronin

Reputation: 558

prepareForSegue not called

I'm using the template master detail application. I have added a modal segue from SplitViewController and given it the identifier "DisplayLoginView".

I call the following from my detailViewController:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:YES];
    [self.splitViewController performSegueWithIdentifier:@"DisplayLoginView"    sender:self.splitViewController];
}

I also have the prepareForSegue method defined in detailViewController:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSLog(@"Source Controller = %@", [segue sourceViewController]);
    NSLog(@"Destination Controller = %@", [segue destinationViewController]);
    NSLog(@"Segue Identifier = %@", [segue identifier]);
    if ([segue.identifier isEqualToString:@"DisplayLoginView"])
    {
        PrometheusLoginViewController *loginViewController = (PrometheusLoginViewController *)segue.destinationViewController;
        loginViewController.delegate = self;
    }
}

Any idea on why it's not called?

Upvotes: 2

Views: 6933

Answers (1)

Janardan Yri
Janardan Yri

Reputation: 751

You're asking the splitViewController to perform the segue, but you're defining prepareForSegue in the detailViewController. They need to be on the same object for prepareForSegue to be triggered.

Upvotes: 6

Related Questions