我正在尝试在UINavigationController
中使用rootViewController
实例化AppDelegate
。我看过这个网站,但是所有的例子都来自Objective-C或者用过的故事板(我试图摆脱它)。 'HomeScreenController`是应用程序的根视图。
编辑:这会显示在控制台中
2015-07-18 14:42:25.376 FastFactsSwift[4749:343495] Failed to instantiate the default view controller for UIMainStoryboardFile 'Main'
- perhaps the designated entry point is not set?
我该如何解决这个问题?
以下代码只会出现黑屏:
AppDelegate.swift:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
self.window?.rootViewController = UINavigationController(rootViewController: HomeScreenController())
return true
}
...
HomeScreenController.swift:
import UIKit
class HomeScreenController: UIViewController, UISearchBarDelegate, UITableViewDelegate{
override func viewDidLoad(){
super.viewDidLoad()
var width = self.view.viewWidth
var height = self.view.viewHeight
//Add stuff to the view
}
...
为什么HomeScreenController
会显示为黑屏?
答案 0 :(得分:0)
问题是没有将AppDelegate
配置为不使用故事板。
How do I create a new Swift project without using Storyboards?