簡體   English   中英

如何使用Swift在AppDelegate中導入UIViewController

[英]How to import a UIViewController in AppDelegate using swift

我有一個名為FirstViewController.swift的UIViewController類,我想在名為MySample的應用程序中的AppDelegate.swift中導入。如何在AppDelegate.swift中導入UIViewController.swift。 我用谷歌搜索,但找不到有效的答案。

提前致謝。

嘗試以下代碼:

    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

  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM