Xamarin.iOS / MonoTouch Storyboard Segue on UIViewController not found - ios

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.

Related

Split View Controller and Segue Unwind

I'm using UISplitViewController scheme for my project, and I put a UITableViewController in DetailedView. So there are two tables on left side (navigation) and right side (content).
Then I've created a new UIViewController and created a segue (Show Detail) from UITableViewController in DetailedView to navigate to this VC. I've also added and Unwind Segue for UIViewController to navigate back to UITableViewController in DetailedView.
But unwind segue doesn't works, because I'm presenting UIViewController segue as Show Detail segue. When I change segue to Modal Segue unwind works correctly, but I'm losing UISplitViewController (navigation master side disappears).
Do you have any ideas to make Unwind Segue work and return to Detailed View?
I'm using UISplitViewController scheme for my project, and I put a UITableViewController in DetailedView.
If that's literally true, it's wrong. The correct architecture, which is what you are given by the Master-Detail template, is:
UISplitViewController
UINavigationController [master]
UITableVieController
UINavigationController [detail]
SomeUIViewController
So your UITableViewController goes where I've written "SomeUIViewController". To navigate from there within the detail view, just push (or show). The user can now navigate back with the Back button, or you can pop in code.

How to make SWRevealViewController a child of another controller in swift

Hi I've a problem I tried to solve it by reading the docs but I couldn't.
I want to the tab bar controller to be the initial VC Not the SWRevealViewController.
The issue is that the slide out menu in side the app not the first vc.
So the question how to make the SWRC there?
Why could not you move your reveal view controller as a last controller in navigation queue and use your controller with "Item" menu as Sw_front? It should work.
As an alternative you can remove the whole reveal view controller from Storyboard and create it manually from your first view controller in navigation queue. And then push.
SWRevealViewController has a method called initWithRearViewController:frontViewController, and you can obtain Sw_rear and Sw_front view controllers with instantiateViewControllerWithIdentifier from Storyboard.
Then, when adding Item menu (manually) to navigation bar, you assign revealToggle: as action and your SWRevealViewController instance as target.
There are some variations of this approach, you can place your SWRevealViewController before the Navigation Controller in Storyboard and specify Navigation Controller as a Sw_front. Then you do not need to instantiate SWRevealViewController manually, but only "Item" menu.
Here could be also useful to removeGestureRecognizers from reveal view controller on viewWillAppearof intermediate view controller in navigation queue and then add back panGestureRecognizer and tapGestureRecognizer on viewWillAppear of the view controller with "Item" menu.
UPDATE
Here is the sample project of using SWRevealViewController in Swift with Tabbar.
I've just taken the sample project from http://www.appcoda.com/sidebar-menu-swift/ and adjusted a little bit.
And what I dislike about using SWRevealViewController with Storyboards is that each new ViewController to be shown, has its own Navigation Controller, but if it works for you, you can keep it.

How to use Navigation Controller inside of UITabBarController with Storyboard on Swift

I'm using swift.
I would like to use Navigation inside of TabBar with Storyboard.
At first, the first display show up inside of tab menu.
But when I move to second display, second display show up without tab menu.
I selected segue type "show (e.g.Push)"
How can I keep displaying tab menu on all views?
In Interface Builder:
Create an UITabBarController and set it as the initial View Controller.
Create an UITableViewController.
Select the UITableViewController and go to the menu bar > Editor > Embed in > Navigation Controller.
Select your UITabBarController and CTRL-drag from it to the UINavigationController.
Choose Relationship Segue > view controllers.
Now, any View Controller you will add in the UINavigationController stack will be presented in the same UITabBarController.
To perform a segue from the first-in-stack UITableViewController connected to the UINavigationController, to another ViewController you must of course first create another ViewController, create a segue to it in Interface Builder, create an identifier for your segue and in your code perform it by calling the appropriate function in Swift like:
optional func performSegueWithIdentifier(_ identifier: String,
sender sender: AnyObject?)
Here's a sample on how your Interface Builder could look like:
Here's a rough overview on how your Storyboard will look like. You have to use Tab Bar Controller as a rootViewController.
Embed UITableViewController to a UINavigationController, so that you always have a back button.
There are endless possibilities for improvement as long as you follow Combined View Controller Interfaces. Here's what a demo will look like with a common tab as you wanted -

Adding toolbar to a ViewController in storyboard

I'm using storyboard to create an iPad app. On the main view I have a toolbar and a bar button item, let's call it "show". Then I have dragged a table view controller into the storyboard. I have also added a subclass of UITableViewController to the files and made the class of the dragged table view controller to be that subclass. And I made a popover segue from the "show" button to the table view controller. It works fine, meaning that when "show" pressed I see the popover showing the correct data that I set in the table view. What I cannot seem to figure out is how to put a toolbar on top of the table view in the popover. I took a step back and used a UIViewController instead of UITableViewController and still cannot add a toolbar by dragging it to the view. Any help will be appreciated.
I ended up putting the TableViewController within a NavigationController and the latter in a PopoverController, all in the code, without using IB. I found this an easier solution to get the toolbar than anything else that might work.

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

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.

Resources