从App Delegate推送View Controller

时间:2016-03-09 06:23:11

标签: ios swift uinavigationcontroller

我正在尝试呈现并推送到另一个Storyboard文件中的视图控制器。但我无法显示TabBar,这里是我的代码,以及我如何设置它的屏幕截图。

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    let rootView = self.window!.rootViewController as! TabBarViewController
    rootView.selectedIndex = 4
    let storyBoard = UIStoryboard(name: "Main", bundle: nil)
    let navVC = storyBoard.instantiateViewControllerWithIdentifier("moreNav") as! UINavigationController
    storyBoard.instantiateViewControllerWithIdentifier("moreView") as! MoreTableViewController
    let vc = navVC.visibleViewController as! MoreTableViewController


    let pdfLockerSB = UIStoryboard(name: "PDFLocker", bundle: nil)
    let pdfvc = pdfLockerSB.instantiateViewControllerWithIdentifier("pdfLockerTable") as! PDFLockerTableViewController

    vc.navigationController?.pushViewController(pdfvc, animated: true)

    return true
}

enter image description here

任何想法我做错了什么?它是一个UITabBarController,链接到一个链接到UITableViewController的UINavigationController。

我已经设置了segue,但我不确定它为什么不执行它。使用推送或执行

1 个答案:

答案 0 :(得分:3)

试试这个

let navVC: UINavigationController =  rootView.viewControllers![4] as! UINavigationController;
let vc = navVC.topViewController as! MoreTableViewController

而不是

let navVC = storyBoard.instantiateViewControllerWithIdentifier("moreNav") as! UINavigationController
let vc = navVC.visibleViewController as! MoreTableViewController