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
"Launch screens may not set custom class names"
提问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 UIViewController
class (IntroVC
). In the storyboard I created a new View Controller
object and set it's class (Identity Inspector
-> Custom Class
-> Class
) to IntroVC
. IntroVC
is a .swift
file 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
错误
IntroVC
介绍VC
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 IntroVC
class in Main.storyboard
.
在 中设置自定义类时发生此错误LaunchScreen.storyboard
。我应该IntroVC
在Main.storyboard
.
Setting the initial VC class in LaunchScreen.storyboard
to UIViewController
and the initial VC class in Main.storyboard
to IntroVC
fixed the problem.
将初始 VC 类设置LaunchScreen.storyboard
为UIViewController
并设置初始 VC 类Main.storyboard
以IntroVC
解决该问题。
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 中检查您的视图控制器,并确保您没有同时设置为自定义类的控制器:
andhas "Is Initial View Controller" checked:
并选中“是初始视图控制器”:
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.Storyboard
file in the Identity Inspector
. Just remove the class name and it will work fine.
发生这种情况的原因是,如果您LaunchScreen.Storyboard
在Identity 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,也许你不小心将它设置为一个视图控制器类。