【发布时间】:2019-07-02 21:50:14
【问题描述】:
在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' cannot beConstructed because it has no access initializers"。
还有其他人遇到过这个问题吗?只是好奇我应该从哪里开始寻找或者我做错了什么。
【问题讨论】:
-
请同时附上您的
ContentView代码。