why show this warning: Unsupported Configuration: Segues initiated directly from view controllers must have an identifier
This happens when you create the segue by dragging from the viewController, rather than from say a UIButton or other element. The reason is that in order to execute the segue programmatically you need to specify an identifier like this:
[self performSegueWithIdentifier:@"BOOK_LEAVE_SEGUE" sender:sender];
Otherwise there is no way of knowing which segue to perform.
So click on the segue in the storyboard, open attributes pane and give it an identifier.
What does this Xcode error mean?
From this SO question: Segues initiated directly from view controllers warning in storyboard xcode
"Segues initiated directly from view controllers must have an
identifier for use with-[UIViewController
performSegueWithIdentifier:sender:]This warning occurs when you drag a segue from the View Controller
icon (aka, not a segue from a button or action) and don't give it a
segue name.You have to give these ones a name or else there's no way to call them
programmatically... which is the only reason why you would link a
segue like this.You should be able to double click the warning to have the storyboard
bring up the offending segue so that you can add a name to it."
Can't find segues without identifiers
a master list of segues that I can look at
Absolutely. Control click on the storyboard's listing in the Project navigator and choose Open As > Source Code. Now you can read — and search — the storyboard as XML. Look for a <segue ... />
without an identifier
attribute.
Can you read the storyboard segue identifier in the receiving view
I guess you are looking for the below method
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
DestinationViewController *dvc = segue.destinationViewController;
dvc.segueIdentifier = segue.identifier;
if ([segue.identifier isEqualToString:@"Button 1"]) {
//
}
}
Changing view controllers programatically and using segues
The problem is that you are loading HomeViewController
as the root view controller:
let homeViewController = storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
view.window?.rootViewController = homeViewController
view.window?.makeKeyAndVisible()
Instead, you want to load a UINavigationController
as the root. Give the navigation controller in your storyboard an ID (such as "mainNavController") and change your startup code to:
let navController = storyboard?.instantiateViewController(identifier: Constants.Storyboard.mainNavController)
view.window?.rootViewController = navController
view.window?.makeKeyAndVisible()
Now, HomeViewController
will be loaded as that navigation controller's "root" controller, and your segues will "push" instead of "present".
Note: I'm assuming your current code (with the optional storyboard?
and view.window?
) already working correctly.
Related Topics
Allow "Auto Lock" While Video Is Being Played
How to Check Text Field Input at Real Time
Creating a Custom Progress Bar with Images
Getting the Action of Uigesturerecognizer in iOS
How to Use Store and Use an Nsmutableattributedstring in Nsuserdefaults
Is Float, Double, Int an Anyobject
Is There a Custom Url Scheme for the Built-In Contacts App
How Can One Enable Keyboard Like in Imessages/Fb Messenger in Landscape Mode at iOS8
Hide a Phone Call Completely in iOS (Jailbreak Device)
Read Binary Qr Code with Avfoundation
Does Swift Not Work with Function Pointers
Fit Image of Random Size into a Uiwebview (Ios)
Nsindexpath? Does Not Have a Member Name 'Row' Error in Swift