如题,在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?
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
}
}
解决方案
40
self.window makekeyandvi啥的把这句话写上,swift忘了这句话咋写,建议先把OC学好