In an iOS 5 Storyboard, how do you push a new scene to the original view controller from a Popover?

12,800

Solution 1

You're expecting the UINavigationController hierarchy to extend itself into a presented popover. It won't. The same goes for presenting modal view controllers. If you were to log self.navigationController in popoverView, you would see that it is nil.

Embed popoverView into it's own UINavigationController. Remember that if you're overriding prepareForSegue:sender: and attempting to configure the popover, you will need to get the topViewController from destinationViewController as the destination is now an instance of UINavigationController.

Solution 2

Sounds like it should work, but if it doesn't try the following: 1. Click the segue that doesn't work and give it an identifier. Let's say it's PopoverToNewSegue.

  1. In your implementation file for the popover view controller, add an action when the button is clicked.

  2. That function should return void and add the following line: [self performSegueWithIdentifier:@"PopoverToNewSegue" sender:self];

That should get your segue running. I've noticed that segues don't always work like you expect them to, but this one works for me without fail.

Share:
12,800

Related videos on Youtube

lnafziger
Author by

lnafziger

I am a former engineer, now a corporate pilot who enjoys programming both for work and as a hobby on the side.

Updated on June 04, 2022

Comments

  • lnafziger
    lnafziger almost 2 years

    I'm creating a popoverSegue from a new view controller and want to push a third view controller onto the original stack. This is how I'm creating the application:

    1. Create a new Single View Application
    2. Select Use Storyboards
    3. Select the MainStoryboard.storyboard file.
    4. Select the only View Controller, change the Title and Identifier to initialView, then select Editor->Embed In->Navigation Controller
    5. Drag two new View Controller objects from the Objects Library onto the canvas
    6. Change the Title and Identifier of the new View Controllers to: popoverView and newView.
    7. Add a Round Rect Button object from the Object Library to initialView and popoverView.
    8. Add a Label object from the Object Library to `newView.
    9. Control click the button in the initialView and drag to popoverView.
    10. Select the Popover option from the Storyboard Segues menu that appears.
    11. Control click the button in the popoverView and drag to the newView.
    12. Select the Push option fromt the Storyboard Segues menu.
    13. Build & Run.

    Click the first button, and the popover appears, but when you click the button within the popover, nothing happens (it should push the new view but doesn't.)

    What I want to do is for it to push onto the Navigation Controller stack, but am not sure how to setup the storyboard for that.

    Any ideas?

  • jrwren
    jrwren over 12 years
    I'm having the same issue. I tried to call performSegueWithIdentifier like you said and it did nothing :(
  • HpTerm
    HpTerm over 11 years
    your explanation just helped me solve my problem (stackoverflow.com/questions/13591559/…). Thank you
  • MiQUEL
    MiQUEL almost 11 years
    could you please add a small example of that?