Segue to another storyboard without using Storyboard Reference?

storyboard reference programmatically
segue to another view controller programmatically
navigate from one storyboard to another swift
segue to another storyboard swift 4
unwind segue to different storyboard
swift segue programmatically without storyboard
how to move from one storyboard to another in ios
how to go from one storyboard to another

I have a button in my App which gives an alert when clicked, and only if the user clicks "OK" - I want to send them to another storyboard. Is it possible to do this in the ViewController? Without a storyboard reference? How will the code look like?

Based on the updated details from your comments, you will need to instantiate your viewController in your storyboard and perform the navigation manually like so:

let alert = UIAlertController(title: "Alert!", message: "Do the thing", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default) { (action) in
    let storyboard = UIStoryboard(name: "Bussturen", bundle: nil)
    let viewController = storyboard.instantiateViewController(identifier: "BussturenViewController") as! BussturenViewController
    //Do any more setup you might need to do for your viewController before navigation
    self.navigationController?.pushViewController(viewController, animated: true)
}
alert.addAction(action)
self.present(alert, animated: true, completion: nil)

Please also note that this assumes that in the Identity Inspector in your storyboard you have your BussturenViewController set as "BussturenViewController"

iOS 9: Staying Organized with Storyboard References, Another hurdle when working with storyboards is collaboration. It's not obvious how one storyboard is connected to another storyboard. tab bar controller in the storyboard and create a segue to the storyboard reference by� In Main.storyboard, drag out a storyboard reference object. In the attributes inspector select your new storyboard from the Storyboard dropdown, then enter your target storyboard identifier in the Referenced ID box. That storyboard reference can now be treated like a regular view controller, so you can make connections to it such as a Show segue.

Place the below code

// Your button tap function
@IBAction func buttonClickAction(_ sender: Any) {
   let alert = UIAlertController(title: "", message: "Show me next view controller", preferredStyle: UIAlertControllerStyle.alert)
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
        self.displayNextViewController()
    }))
    alert.addAction(UIAlertAction(title: "NO", style: .default, handler: nil))
    self.present(alert, animated: true, completion: nil)
}

// Function which loads next view controller
func displayNextViewController() {
  let nextViewController = NextViewController() as UIViewController
  self.navigationController?.pushViewController(nextViewController, animated: true)
}

You can customize the nextVC instantiation based on your requirement. Hope this helps for you!

Segue to another storyboard?, Create segue between ViewController and Storyboard Reference You should not place UITabBarControllers in a UINavigationController. Xcode will create a new .storyboard file and will put the scenes you selected into it. In Main.storyboard, you’ll find a new item created. This item is referring to another set of scenes in another storyboard file. You can also insert a Storyboard Reference from the Object library if you prefer to link scenes yourself. If you build and run

by looking at the help from all the answers, I was able to find a solution:

    func displayNextViewController() {

    let storyBoard : UIStoryboard = UIStoryboard(name: "Bussturen", bundle:nil)
    let nextViewController = storyBoard.instantiateViewController(withIdentifier: "BussturenViewController") as! BussturenViewController
    nextViewController.modalPresentationStyle = .fullScreen
    self.present(nextViewController, animated:false, completion:nil)
}

@IBAction func bussturenTapped(_ sender: UIButton) {


    let alert = UIAlertController(title: "", message: "Show me next view controller", preferredStyle: UIAlertController.Style.alert)
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: {_ in self.displayNextViewController() }))

    alert.addAction(UIAlertAction(title: "NO", style: .default, handler: nil))
    self.present(alert, animated: true, completion: nil)



}

How to use storyboard references to simplify your storyboards, that connect one storyboard to another, using any identifier or presentation segue you want. Storyboard references are easy to use, but don't get a lot of use because they like a regular view controller, so you can make connections to it such as a Show segue. Verify receipts without your own server. On top of this, segue objects are used to prepare for the transition from one view controller to another. When a segue is triggered, before the visual transition occurs, the storyboard runtime invokes prepareForSegue:sender: method of the current view controller (in our example, it’s the RecipeBookViewController).

Refactoring with Storyboard References, The disadvantage was that you could not then create segues in Interface Builder between the different Storyboards. Instead you needed to wire� This is very simple example how to use Xcode storyboard references. hope everyone like it. This is my first video. please comment and suggest how to improve. Thanks.

Organizing Storyboards With Storyboard References, Apple introduced storyboard references in iOS 9 and macOS 10.11 with the goal of A storyboard reference ties multiple storyboards together, creating one, references, you no longer have an excuse to not use storyboards. Using Segues. Use segues to define the flow of your app’s interface. A segue defines a transition between two view controllers in your app’s storyboard file. The starting point of a segue is the button, table row, or gesture recognizer that initiates the segue. The end point of a segue is the view controller you want to display.

iOS Storyboards: Segues and More, In bigger projects, the storyboard file can get crowded with many But fear not, there is a remedy for that: Storyboard references. This item is referring to another set of scenes in another storyboard file. You don't create segues programmatically - it is the storyboard runtime that creates them for you. You can normally call performSegueWithIdentifier: in your view controller's code, but this relies on having a segue already set up in the storyboard to reference.

Comments
  • Thanks for your answer, code gives no error. However, when I try to run it I get this "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x6000010b5080>) doesn't contain a view controller with identifier 'BussturenViewController'" - i'm assuming its regarded to what you said about the identity inspector? I didn't fully understand what you mean. In which storyboard should I change it?
  • I was able to get rid of the error, but still, it does not send me to the new storyboard when clicking OK.
  • @lamalama69 Are you actually using a navigationController? I put that in just as an assumption, but if you aren't you will need to present the viewController in a different way.
  • thanks for your reply. i'm getting a few errors with this code. on the addAction for "OK" I get the error "Value of type 'ViewController' has no member 'displayNextViewController'" - also on the func for displayNextViewController, I get this error "Attribute 'private' can only be used in a non-local scope"
  • thanks for helping. I get no errors now, but it does not send me to the other storyboard when clicking OK on the alert. do you see what I have done wrong? The storyboard I want to have displayed is called "Bussturen.storyboard" and its viewcontroller is "BussturenViewController.swift". here is my code: imgur.com/a/xix1ims