0
votes

I'm trying to segue from a button to a new viewController which is in another storyBoard, via a custom class. This is how the custom class looks.

import UIKit
import Foundation

class NavigationController{

    static func segueToNextViewController(#storyboardName: String){
        var eventsBoard: UIStoryboard = UIStoryboard(name: storyboardName, bundle: NSBundle.mainBundle())
        var nextViewController = eventsBoard.instantiateInitialViewController() as! UIViewController
        self.presentViewController(nextViewController, animated: true, completion: nil)
    }   
}

But I'm having an error stating: 'NavigationController.Type' does not have a member named 'presentViewController' on this line self.presentViewController(nextViewController, animated: true, completion: nil)

any help will be really appreciated

2

2 Answers

0
votes

Try out this,

import UIKit
import Foundation

class NavigationController{

        func segueToNextViewController(storyboardName: String){
        let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("#YourViewControllerName") as! UIViewController
    self.presentViewController(vc, animated: true, completion: nil)
    }   
}

*make sure that place a name your View Controller storyboard ID and paste the same name in to #YourViewControllerName in the code

0
votes

sorted. just needed to create an extension of the UIViewController and put this code in it.