0

I have a photo selection flow that that goes as such:

VC1 push to VC2, present modal, dismiss modal, push VC3.

Upon dismissing the modal view however, self.navigationController is null

Modal View:

[self dismissViewControllerAnimated:YES completion:^{
                                FBGalleryVC *vc = [[FBGalleryVC alloc] init];
                                [vc showVC3];
                            }];

Triggers VC2:

- (void)showVC3 {
    NSLog(@"NavController=%@",self.navigationController);
    VC3 *vc3 = [self.storyboard instantiateViewControllerWithIdentifier:@"VC3"];
    [self.navigationController pushViewController:vc3 animated:YES];
}

It's unclear to me why the navigationController is getting 'unset' or returning as null.

Gabriel M Sharp
  • 335
  • 1
  • 6
  • 17
  • How and where is `showVC3` called? – Wain Mar 10 '15 at 14:39
  • Sorry, edited to show, it's called after the completion of dismissViewControllerAnimated. – Gabriel M Sharp Mar 10 '15 at 14:40
  • How did you push the modal viewcontroller? – Alex Cio Mar 10 '15 at 14:41
  • This is how I present the modal vc. `ImageCropperVC *vc = [[ImageCropperVC alloc] initWithImage:cell.imageview.image]; [self.navigationController presentViewController:vc animated:YES completion:nil];` – Gabriel M Sharp Mar 10 '15 at 14:42
  • how did you push the VC2? – Teja Nandamuri Mar 10 '15 at 14:48
  • This is how we push the VC2 onto VC1, it uses a Storyboard segue so maybe that's something? `- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"FBGalleryVC" sender:nil]; }` – Gabriel M Sharp Mar 10 '15 at 14:52
  • 2
    it is `nil` because the `vc` is a brand new instance of the `FBGalleryVC`, you are creating it in the completion block and it has never gone into any navigation stack, therefore its `navigationController` property is `nil`. – holex Mar 10 '15 at 14:58
  • Many thanks to @holex - Very silly mistake on my part. – Gabriel M Sharp Mar 10 '15 at 15:01

0 Answers0