在SceneDelegate.swift
中,以下代码返回错误消息“使用未解析的标识符'ContentView';您是指'ContentMode'吗?”。
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options
connectionOptions: UIScene.ConnectionOptions) {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()
}
此错误会导致程序构建失败。令人惊讶的是,当我创建具有完全相同的SceneDelegate.swift
的新项目时,ContentView没有问题。
如果将ContentView更改为ContentMode,它将返回错误“ ContentMode”无法构建,因为它没有可访问的初始化程序。”
还有其他人遇到过这个问题吗?只是好奇我应该从哪里开始寻找或做错了什么。
答案 0 :(得分:0)
想出了这一点。如果有人好奇,我更改了ContentView.swift
文件名,但没有在SceneDelegate.swift
中更新它。
因此,如果将ContentView.swift
文件更改为BetterNameView.swift
,则需要将SceneDelegate.swift
中的上述代码从ContentView()
更新为BetterNameView()