2

I'm running Xcode 7 beta 5 and I have a storyboard with a tab bar controller featuring 4 items. Each item is a UIViewController. I created a custom class that is a subclass of UIViewController.

When I go to the storyboard, click on one of the UIViewControllers, go to the Identity Inspector, click on custom class, and try to name my custom class it says,

"Launch screens may not set custom classnames"

Am I doing something wrong? I thought this was the way to associate a storyboard's UIViewController with your custom view controller.

thecodingmate
  • 331
  • 6
  • 16

5 Answers5

6

The problem is that you are trying to assign a custom class to launch screen. Launch screens main function is to display a view until application loads (not to implement application logic). You should create a new view controller representing object in storyboard (this one should be displayed after application load) and assign a custom class to it.

Daumantas Versockas
  • 797
  • 1
  • 10
  • 29
  • Do I create a new storyboard? – thecodingmate Aug 24 '15 at 07:08
  • The best practice is to separate launch screen in xib file. You should create a LaunchScreen.xib and set it in application settings -> General -> App Icons and Launch Images (Launch Screen File: LaunchScreen.xib). Whole application views logic should be implemented in a storyboard, which should be also provided in application settings -> General -> Deployment info (Main interface: Main.storyboard). In this way you will not be confused by launch screens and views. – Daumantas Versockas Aug 24 '15 at 07:14
  • Also, you shouldn't name your main storyboard `LaunchScreen.storyboard`. Storyboard is not made to implement one view. It is made to implement whole views and interactions logic. You should better name it `Main.storyboard`. Launch screen is a single view. To represent a single view there are `.xib` files. For launch screen it is good idea to name it `LaunchScreen.xib` – Daumantas Versockas Aug 24 '15 at 07:16
  • Ok. For some reason they gave me a storyboard for the launch screen by default. I get it now. Thanks everyone! – thecodingmate Aug 24 '15 at 07:21
1

As the error message says, custom classes are now forbidden in Launch Screens in Xcode 7. See e.g. here as well

Community
  • 1
  • 1
JonEasy
  • 921
  • 10
  • 22
  • I was able to create a new storyboard, add a VC to it, set a custom class to it, then specify that as launch storyboard. However it seems to ignore the orientation setting I specified. But subclassing that way might just actually work. Tried using Xcode 9, iOS 11.x. – Jonny Apr 20 '18 at 05:49
1

If you are trying to customize your Splash Screen then you can create your first view controller as Splash Screen and then set a custom class there.

To tell the system that not to load launch screen just change the settings as mentioned below...

General Tab --> Launch Screen File --> Select "Main" (Basically it's Main Storyboard).

Rohit Kumar
  • 877
  • 6
  • 20
0

You can set a custom class to any storyboard component except the launchscreen.xib file.

Rukshan
  • 7,902
  • 6
  • 43
  • 61
0

This worked for me. I deleted LaunchScreen.storyboard and in main.storyboard I added the custom class which did not give any error later. Hope it helps someone else too.

UsamaMan
  • 695
  • 10
  • 28