简体   繁体   中英

How to import a UIViewController in AppDelegate using swift

I have UIViewController class named FirstViewController.swift which I want to import in AppDelegate.swift in my app named as MySample.How to import a UIViewController.swift in AppDelegate.swift. I googled but couldn't find answers that are working.

Thanks in advance.

Try this Code:

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String, annotation: AnyObject?) -> Bool {
    var rootViewController = self.window!.rootViewController as UINavigationController
    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    var FirstViewController = mainStoryboard.instantiateViewControllerWithIdentifier("StoryBoardID") as FirstViewController
    rootViewController.pushToViewController(FirstViewController, animated: true)

    return true

  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM