简体   繁体   English

为什么我的初始 ViewController 没有出现在模拟器上,只有 Hello World?

[英]Why is my initial ViewController not showing up on simulator only Hello World?

I am following the Udemy Advanced iOS and Firebase tutorial.我正在关注 Udemy Advanced iOS 和 Firebase 教程。 His tutorial is on ios 8 and I am on 10, plus I am on Xcode 11.3 and he is on 9 I think.他的教程在 ios 8 上,我在 10 上,另外我在 Xcode 11.3 上,我认为他在 9 上。

Anyway, I followed the tutorial and when I launch it I get an error about LaunchScreen cannot use custom classes.无论如何,我遵循了教程,当我启动它时,我收到一个关于 LaunchScreen 无法使用自定义类的错误。 So I unchecked use as Launch Screen.所以我取消选中用作启动屏幕。 This now allows the simulator to run, but when it does I don't see the app I have built.这现在允许模拟器运行,但是当它运行时,我看不到我构建的应用程序。 All is show is a white screen with "Hello World" on it?只是显示的是一个带有“Hello World”的白屏?

For some reason when I created a Single View app in Xcode it only created a LaunchScreen.storyboard so that is where I built my UI.出于某种原因,当我在 Xcode 中创建一个单一视图应用程序时,它只创建了一个 LaunchScreen.storyboard,所以我在那里构建了我的 UI。 I have noticed other tutorials Xcode automatically creates the Luanch storyboard and the Main storyboard?我注意到其他教程 Xcode 会自动创建 Luanch 故事板和主故事板吗?

The reason why you see the "Hello, World!"你看到“Hello, World!”的原因is you have created a SwiftUI app你是否已经创建了一个 SwiftUI 应用程序

For Xcode 11对于 Xcode 11

When creating a new Xcode project and the user interface option is selected as SwiftUI as shown below当创建一个新的 Xcode 项目并且用户界面选项被选择为SwiftUI 时,如下所示

SwiftUI 选项

Then the initial project files will only contain the LaunchScreen.storyboard and the other files listed below.然后初始项目文件将只包含 LaunchScreen.storyboard 和下面列出的其他文件。 To configure the UI one needs to write SwiftUI code in the ContentView.swift要配置 UI 需要在ContentView.swift 中编写 SwiftUI 代码

SwiftUI 文件

When creating a new Xcode project and the user interface option is selected as Storyboard as shown below当创建一个新的 Xcode 项目并且用户界面选项被选为Storyboard 时,如下所示

故事板选项

Then the initial project files will contain the LaunchScreen.storyboard and the Main.storyboard as shown below.然后初始项目文件将包含LaunchScreen.storyboardMain.storyboard ,如下所示。

故事板文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM