Search code examples
swiftseguexibviewcontrolleruitableview

Show ViewController from XIB-file-Button - Swift


is there a way how to segue from a xib-file (custom TableViewCell) to another ViewController in the Main.storyboard.

There's no possibility to drag a segue, like within the main storyboard.

In the cell I've got a button, from where I want to change the view. How can I solve it?

Thanks!


Solution

  • You can always instantiate a view controller from your Storyboard and present it on button tapped:

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("ViewControllerID") as UIViewController
        self.presentViewController(vc, animated: true, completion: nil)