xcode “启动屏幕可能不会设置自定义类名称”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32878827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:58:41  来源:igfitidea点击:

"Launch screens may not set custom class names"

iosxcodeswiftuiviewcontrolleruistoryboard

提问by Ty Pavicich

I'm trying to set the initial view controller to a custom class. In previous versions this worked but for some reason I cannot do it now.

我正在尝试将初始视图控制器设置为自定义类。在以前的版本中,这有效,但由于某种原因我现在不能这样做。

I have a UIViewControllerclass (IntroVC). In the storyboard I created a new View Controllerobject and set it's class (Identity Inspector-> Custom Class-> Class) to IntroVC. IntroVCis a .swiftfile with functions viewDidLoad()and didReceiveMemoryWarning()of class IntroVC: UIViewController.

我有一个UIViewController班级(IntroVC)。在故事板中,我创建了一个新View Controller对象并将其类(Identity Inspector-> Custom Class-> Class)设置为IntroVC. IntroVC是一个.swift具有函数viewDidLoad()didReceiveMemoryWarning()的文件class IntroVC: UIViewController

Here are screenshots of XCode

这是 XCode 的截图

Error

错误

Error

错误

IntroVC

介绍VC

IntroVC

介绍VC

Storyboard

故事板

Storyboard

故事板

Anyone know how to solve this? What's up with this version of XCode?

有谁知道如何解决这个问题?这个版本的 XCode 怎么了?

回答by Ty Pavicich

I made a really simple mistake.

我犯了一个非常简单的错误。

This error occurred when a custom class was set in LaunchScreen.storyboard. I should have set my custom IntroVCclass in Main.storyboard.

在 中设置自定义类时发生此错误LaunchScreen.storyboard。我应该IntroVCMain.storyboard.

Setting the initial VC class in LaunchScreen.storyboardto UIViewControllerand the initial VC class in Main.storyboardto IntroVCfixed the problem.

将初始 VC 类设置LaunchScreen.storyboardUIViewController并设置初始 VC 类Main.storyboardIntroVC解决该问题。

XCode 7.0.1 is fine. The mistake is my own.

XCode 7.0.1 很好。错误是我自己的。

回答by Josh

Go through your View Controllers in Main.storyboard and make sure you don't have one that is bothset to a custom class:

在 Main.storyboard 中检查您的视图控制器,并确保您没有同时设置为自定义类的控制器:

enter image description here

在此处输入图片说明

andhas "Is Initial View Controller" checked:

选中“是初始视图控制器”:

enter image description here

在此处输入图片说明

You can only do one or the other. Somehow I had "Is Initial View Controller" still checked by mistake, and it took me a while to hunt that down!

你只能做一个或另一个。不知何故,我仍然错误地检查了“是初始视图控制器”,我花了一段时间才找到它!

回答by Ramakrishna

This occurs due to if you are set the class name for the LaunchScreen.Storyboardfile in the Identity Inspector. Just remove the class name and it will work fine.

发生这种情况的原因是,如果您LaunchScreen.StoryboardIdentity Inspector. 只需删除类名,它就会正常工作。

回答by itsprof

Check if you're changing the "LaunchScreen.xib" file view class in the identity inspector. It should be a standard UIView, maybe you set it to a view controller class by accident.

检查您是否正在更改身份检查器中的“LaunchScreen.xib”文件视图类。它应该是一个标准的 UIView,也许你不小心将它设置为一个视图控制器类。