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

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 and Identifier to initialView, then select Editor->Embed In->Navigation Controller
Drag two new View Controller objects from the Objects Library onto the canvas
Change the Title and Identifier of the new View Controllers to: popoverView and newView.
Add a Round Rect Button object from the Object Library to initialView and popoverView.
Add a Label object from the Object Library to `newView.
Control click the button in the initialView and drag to popoverView.
Select the Popover option from the Storyboard Segues menu that appears.
Control click the button in the popoverView and drag to the newView.
Select the Push option fromt the Storyboard 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?

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.

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

How to show a view controller using a navigation controller segue, including back segue (Swift)

I have to view controller, One has a button and the other is embed in a navigation controller. I Don't know how to make a proper segue to that second view controller including a back (unwind) segue. That is in swift.
You're going to use a navigation controller. Go and select your view in the storyboard, and select Editor -> Embed In -> Navigation Controller. Do the same for the second view. Now, add a button in the first view that connect to the second view on a click. Make sure when you drag and drop that it's a push segue.
Voila! You should now have your navigation controller working.

Update UINavigationController when clicked on menu

This is my current storyboard.
I have an initial view (Activity) embedded into a Navigation Controller, which has a top left navigation item (barely visible button) which segues to a menu (Guillotine Menu View Controller) with different options. How do I set this up to open a different ViewController embedded in the same navigation controller when I click on an option in the menu?
BTW I am using this library as the menu view controller.
You can do it as follow:
New your different view controller in the storyboard.
Cmd+drag from the button to the view controller.
In the pop-up menu, select the "push" segue.
I think you need a way to make the menu push new viewcontroller to the navigation controller that presented it. I have an idea but I can't try it now, you can try it and tell me if anything isn't clear
1- Add delegate properety to your GuillotineMenuViewController
2- In prepareForSegue in your viewcontrollers if the segue is for displaying the menu, set the menu delegate to self
3- Make menu buttons' actions call the menu's delegate with the name (or better the storyboard ID) of the viewcontroller it should push
4- In the delegate function close the menu, and check if the viewcontroller isn't the one already on top, instantiate it with the corresponding storyboard ID and push it

How to link items from a tabbar item to another viewcontroller

I have a UITabbar and added additional UITab Bar Items. I then want to link (create a segue) to another view controller, but when I drag to create a segue, I do not get the popup menu letting me choose between 'push' and 'modal'.
How can I create a segue to another view controller?
It is not possible to create a segue inside the Interface Builder using a UITab Bar Items, it has to be done using a UITabViewController (dragging directly from it).
A workaround could be to do it programmatically, listening when a item is selected inside the UITabbar and use the pushViewController:animated: method from the navigation controller to make the push, but not sure if this will work.

Xamarin.iOS / MonoTouch Storyboard Segue on UIViewController not found

The following situation in Xamarin.IOS/Monotouch applies:
I'm using two viewcontrollers, VCOne and VCTwo and I have assigned them two custom classes in XCode the Storyboard editor (MYVCOneClass and MyVCTwoClass).
Then I drag a segue from VCOne (from the viewcontroller in the left listing) to the VCTwo viewcontroller instance in the editor part and select "Push".
I name the segue "OneToTwoSegue".
My question
When I perform the following call from a button click eventhandler in the VCOne class:
this.performSegue("OneToTwoSegue", this);
I get a runtime error saying that the OneToTwoSegue cannot be found on the MyVCOneClass object.
Does anyone know why i cannot call this segue from code like this? I know i've seen segues working when i link them to cell's, buttons and alike...
If you are doing a "push" segue, your first view controller needs to be the root view controller of a UINavigationController.
So in your storyboard, drag and drop a UINavigationController, delete the tableview and the ViewController that's attached by default, and then make VCOne the root view controller (the same way you would make a segue - hold control and drag from the UINavigationController to the UIViewController and then click root view controller.
Your Segue should work fine after. Just make sure that the UINavigationController is set as the first screen (that little arrow that points to the left should be moved from VCOne to the UINavigationController)
EDIT:
I have uploaded a screenshot of a sample storyboard I created to demonstrate this to you.
VCOne is the root view controller of the Navigation Controller. And there is a segue from VCOne to VCTwo called OneToTwoSegue. With this, your code on your button click will work perfectly.

Why nothing happen when connecting UITableViewCell to UInavigationcontroller

I have UITableView with Static cells. I control-drag from one of these static cells to another UINavigationcontroller and select "Push". I notice nothing happen, when I run the app and tap on the static cells.
However, when I do the same thing & choose "Modal" it works fine. Did I miss something?
You can only use a "Push" transition when segueing between view controllers within a parent UINavigationController.
Your Navigation Controller should be your app's initial view controller. Also when your table cell is tapped you'll want to segue to a View Controller (probably a custom UIViewController subclass), not a UINavigationController.
Make sure you have set your storyboard up with the following:
A UINavigationController - this should be set as the Initial View Controller for your app. Check that the checkbox "Is Initial View Controller" is checked in the Attributes inspector pane when the navigation controller is selected in the storyboard.
A UITableViewController - this should be set at your navigation controller's Root View Controller (there should be an arrow pointing from the nav controller to the tableview controller that looks like a segue but has a different icon in the middle)
Another View Controller - this is the view controller you want to segue to when clicking on your table cell, probably a customer UIVewController subclass you've created. Note that it should probably NOT be a navigation controller.

Resources