single view application中删除默认的scene,创建导航视图不能显示

如题,在xcode 7.3中创建的single view application后,删除了默认的scene,然后拖动一个UINavigationController到SB,这时生成两个场景,其中一个是UINavigationController的实例(ID:test),另一个是UITableViewController的实例,此时编写AppDelegate.swift文件,大致如下(省略了其它默认方法):程序能运行,但是显示为黑屏
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    var navigationcontr:UINavigationController?
 
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        
        let mainSB = UIStoryboard(name: "Main", bundle: nil)
        self.navigationcontr = mainSB.instantiateViewControllerWithIdentifier("test") as? UINavigationController
        
        self.window?.rootViewController = navigationcontr
        return true
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章