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
}
}
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
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.