Matisse VerDuyn
Matisse VerDuyn

Reputation: 1138

Modal UIViewController will not push to next UIViewController

The start of the structure is as follows...

UITabBarController -> UINavigationController(s)

From each of the UINavigationControllers, I have a UIBarButtonItem that modally presents a UIViewController.

This UIViewController has a MKMapView with pins at multiple locations. When clicked, they display an annotation with a disclosure button.

Within this UIViewController, it is my intention to push a detail page (UITableViewController) when pressing the disclosure button of the annotation. The method calloutAccessoryControlTapped: receives the appropriate pin, but the transition to the next controller fails.

I have tried every combination of the following methods...

  1. [self.navigationController ...]
  2. [self.parentViewController ...]
  3. [self.parentViewController.navigationController ...]

with the method being either...

  1. presentModalViewController:
  2. pushViewController:

I have done all of these with the UIViewController being on its own, and also with it embedded inside of a UINavigationController.

All of these properties return null...

  1. self.navigationController
  2. self.parentViewController
  3. self.parentViewController.navigationController

This is the first time I've used storyboard for an Xcode project. Am I missing a step?

Upvotes: 0

Views: 1324

Answers (1)

T.J.
T.J.

Reputation: 3960

Try getting rid of the code and implementing the transitions in storyboard by control dragging from the button to the view controller you wish to load modally. When the "Storyboard Segue" menu pops up select "modal". In the modal view controller, I like to use code to return from the modal by calling:

[self dismissModalViewControllerAnimated:YES];

To Presenting Storyboard View Controllers Programmatically scroll to that section in gravityjack on the link provided.

For example, I have a view controller that I created in storyboard which I can call programmatically with the following two statements:

    SettingsViewController *settingsVC = [self.storyboard instantiateViewControllerWithIdentifier:@"settingsVC"];
    [self.navigationController pushViewController:settingsVC animated:YES];

Upvotes: 0

Related Questions