我希望在一个快速的类而不是情节提要中更改应用程序的初始视图控制器。运行时,代码返回一个Thread 1: signal SIGABRT
,我知道这里有很多问题,但是我已经尝试了他们推荐的所有方法,但无法使其正常工作。大多数帖子都没有针对Swift 5的答案,因此我缺少在Swift版本中更改的内容吗?
这是我AppDelegate.swift中的代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "ViewController")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
return true
}
这里是我的故事板ID为“ ViewController”的错误,但我收到的错误
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x600000dcd8c0>) doesn't contain a view controller with identifier 'ViewController''
Xcode版本:11.2视图控制器名称:ViewController
任何帮助将不胜感激!