In an iOS 5 Storyboard, how do you push a new scene to the original view controller from a Popover?
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.
In your implementation file for the popover view controller, add an action when the button is clicked.
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.
Related videos on Youtube
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, 2022Comments
-
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:
- Create a new
Single View Application
- Select
Use Storyboards
- Select the
MainStoryboard.storyboard
file. - Select the only View Controller, change the
Title
andIdentifier
toinitialView
, then selectEditor->Embed In->Navigation Controller
- Drag two new
View Controller
objects from the Objects Library onto the canvas - Change the
Title
andIdentifier
of the new View Controllers to:popoverView
andnewView
. - Add a
Round Rect Button
object from the Object Library toinitialView
andpopoverView
. - Add a
Label
object from the Object Library to `newView. - Control click the button in the
initialView
and drag topopoverView
. - Select the
Popover
option from theStoryboard Segues
menu that appears. - Control click the button in the
popoverView
and drag to thenewView
. - Select the
Push
option fromt theStoryboard Segues
menu. - 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?
- Create a new
-
jrwren over 12 yearsI'm having the same issue. I tried to call performSegueWithIdentifier like you said and it did nothing :(
-
HpTerm over 11 yearsyour explanation just helped me solve my problem (stackoverflow.com/questions/13591559/…). Thank you
-
MiQUEL almost 11 yearscould you please add a small example of that?