Swift segue identifier always nil, Storyboard ID not working - ios

I'm trying to use a Storyboard ID to tell what View I'm segue to, and based on that, pass on certain information. But no matter what I do, the segue.identifier is always nil. Heres a screenshot of my settings for the view I'm segueing to:

Select the segue on the storyboard, and this is the segue identifier.

Related

Do we need a Storyboard ID in iOS Xcode

I am setting up a basic iOS app and saw the Storyboard ID section of the Identity Inspector (as well as the Use Storyboard ID checkbox) and was curious as to whether this is actually something I need to create an app. If so what do I need to set this field to given the use below:
More specifically I am setting up 2 simple views and 2 corresponding viewcontrollers in my app. I was just trying to create a simple button to go from the first view to the second view and was using this method for the button which would ultimately transition from the first view to the second view once it was pressed:
let vc = self.storyboard?.instantiateInitialViewController(withIdentifier: "SecondViewControllerID") as! TransitionViewController
The view controller for the second view I want to be the destination of the button is named TransitionViewController. I borrowed this code from some samples and "SecondViewControllerID" is the name of the storyboard from the sample I'm borrowing from. In my Xcode, the Storyboard ID field is blank at the moment.
You need to set the storyboard id to SecondViewControllerID or ctrl-drag from the button to the destination vc through segue
Explanation :
Storyboard identifier is a unique key set for a vc inside storyboard to identify it when you load with instantiateInitialViewController
Regarding segue : CTrl-drag from the button to destination and from the popup select show
and don't write any code inside button action
The storyboard id ia mainly used when you have more than one StoryBorad.
if you have 2 storyborads you can initialize the vc by using
var vc = UIStoryboard(name: "main", bundle:nil).instantiateInitialViewController(withIdentifier: "SecondViewControllerID") as! TransitionViewController
and give "SecondViewControllerID" in Storyboard ID section of the TransitionViewController Identity Inspector.

Open the same view from different view controllers

I have the following scenario: I have a view controller and want to navigate programmatically to another view f.e. to give the user the ability to change settings.
So I have VC1 and VC_settings and a present modally segue between those controllers. I gave the segue an identifier and call it like this:
performSegue(withIdentifier: "SegueToSettingsView)
Ok, that works without any problems. The settings view is opened and I can navigate back to VC1.
Now I want to have the same functionality in another view controller VC2. I want to reuse the settings view but the problem is that the segue is already connected between VC1 and VC_settings and I can't connect a new one for VC2.
And if I try to call the existing segue with the coce above in VC2 then the app crashes.
In swift it is possible to create segues from multiple views two one viewcontroller. Here I have set it so there are segues from VC1 to Settings and VC2 to settings which should work.
Hope it helped
Since you have VC1 and VC_settings connected with segue named "SegueToSettingsView" also the perform selector is working fine.
As per your need make another segue from VC2 to VC_Settings and give a different name for it. then make use of below code to perform segue.
performSegue(withIdentifier: "SegueToSettingsViewFromVC2")
Steps to make segue:
Then select the connection and set identifier

How to show segue from bottom of the screen

I created a segue between two controllers(A, B). In controller A, I am using "performSegueWithIdentifier" method to show controller B's view. However, I want to add an animation on presenting the B. I want it to show/hide from the bottom of the screen. How should I do this?
I achieved this using Present As Popover when choosing the kind of segue in Attributes Inspector. Make sure you point your anchor to the view controller you are segueing from, this answer was pretty helpful.
Make sure you give it an identifier (using this identifier below) and use the typical perform segue code whenever you wish to perform the segue:
dispatch_async(dispatch_get_main_queue()) {
[unowned self] in
self.performSegueWithIdentifier("Identifier", sender: self)
}
Make sure you replace "Identifier" string with a string of your own segue identifier.

Unable to programmatically "push" viewcontroller using showSegue in IOS8

I have defined a segue from source tableview controller to another and trying to programmatically transition to the destination controller upon click of a UITableViewCell using the following statement:
[self performSegueWithIdentifier:#"pushToDestinationViewController" sender:self];
However, I find that the segue doesn't result in a "push" to the destination view controller.
On the other hand, if I wire the segue to a specific cell in the source view controller it works.
In addition, if I call the destination viewcontroller programmatically using:
[self showViewController:DestinationViewController] it works.
Can someone advise if this is a known issue in iOS 8 or if I am missing something here.
Did you have a segue in your Storyboard called pushToDestinationViewController? You will need to make sure that you have this segue in your Storyboard first like below.
Or, if you just want to simply push another view controller, you can just use [self.navigationController pushViewController:destinationViewController].

iOS and xcode: how to give a segue a "storyboard id" so that I can programmatically manipulate it

I am wanting to create a modal segue from a view controller to an a new view, but not by linking the segue action to a button or anything. Instead, I'd like to just set the segue up so that I can call it in pageDidLoad and have it automatically execute if I want.
To do this, I need to be able to reference the segue, such as this:
[self performSegueWithIdentifier:#"mySegue" sender: ...];
After I control-click-drag a connection in storyboard to create a segue, how can I give it a name for later reference? Thanks!
Link the segue action from curent viewController to new view controller. I think this you want, see the screenshot.
This link will help you for remaining code.
Nevermind! In the details pane sidebar of xcode, under the third tab there is an "Identifier" field that can be filled out!

Resources