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

I am creating a popoverSegue from a new view controller and want to push the third view controller into the original stack. This is how I create the application:

  • Create a New Single View Application
  • Choose Use Storyboards
  • Select the MainStoryboard.storyboard file.
  • Select a single view controller, change the Title and Identifier values ​​to initialView , then select Editor->Embed In->Navigation Controller
  • Drag two new View Controller objects from the object library onto the canvas
  • Change the Title and Identifier new view controllers to: popoverView and newView .
  • Add a Round Rect Button object from the object library to the initialView and popoverView .
  • Add a Label object from the object library to `newView.
  • Click the button in the initialView and drag it onto the popoverView .
  • Select the Popover option from the Storyboard Segues menu that Storyboard Segues .
  • Control the mouse button on the popoverView button and drag it to the newView .
  • Select the Push option from the Storyboard Segues menu.
  • Build and run.

Click the first button and a popup will appear, but when you click the button inside the popover, nothing happens (it should cause a new view, but it doesn’t.)

I need to want it to push the Navigation Controller stack, but I'm not sure how to set up the storyboard for this.

Any ideas?

+8
ios xcode ios5 storyboard uipopovercontroller
source share
2 answers

You expect the UINavigationController hierarchy to extend to the popover provided. This is not true. The same can be said about the presentation of modal controllers. If you logged in self.navigationController in a popoverView , you will see that it is zero.

Paste popoverView into your own UINavigationController . Remember that if you override prepareForSegue:sender: and try to configure popover, you will need to get topViewController from destinationViewController , since the destination is now an instance of UINavigationController .

+6
source share

It seems like it should work, but if it has not tried the following: 1. Click on the segment that does not work, and give it an identifier. Let's say this is PopoverToNewSegue.

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

  • This function should return void and add the following line: [self performSegueWithIdentifier: @ "PopoverToNewSegue" sender: self];

That should make you work. I noticed that segues do not always work as you expect, but it works for me necessarily.

+1
source share

All Articles