"Launch screens may not set custom class names" - ios

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.
Here are screenshots of XCode
Error
IntroVC
Storyboard
Anyone know how to solve this? What's up with this version of XCode?

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.
Setting the initial VC class in LaunchScreen.storyboard to UIViewController and the initial VC class in Main.storyboard to IntroVC fixed the problem.
XCode 7.0.1 is fine. The mistake is my own.

Go through your View Controllers in Main.storyboard and make sure you don't have one that is both set to a custom class:
and has "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!

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.

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.

Related

iOS Development: Is it necessary to change the class of the View Controller in the storyboard?

I am currently learning iOS development with Objective C. I am facing a couple of issues and I was wondering whether someone could give me some clarifications about xCode. I was reading a book on iOS and I was following it's instructions.
It was saying to create a header and an implementation file with the name test.h and test.m respectively. The test class will have UIViewController as superclass. This is all very fine...
Then, from the instructions, it says to drag out a View Controller from the object library onto the storyboard. Then, the book says:
"Now that the view controllers is in place, it’s time to set it up with the correct controller class. Select the view controller and bring up the Identity Inspector. In the Custom Class section of the inspector, change the class to test, and press Return to set it."
My question is: Is it really important to change the class of the view controller to test? Why can't I let the class remain as UIViewController? If I let the class remain as UIViewController, will the outlets and actions created on the view controller in the storyboard not be able to 'communicate' between the View Controller in the storyboard and the test.h and test.m files?
Thanks for reading
Kindest Regards
Yes, it is imperative that you set the class. Fortunately Xcode will not allow you to add outlets in the storyboard if the class set does not define them. If you don't set the correct class then the wrong class will be instantiated at runtime and your custom code will not run.
Keep in mind that the storyboard contains an archive of your design which can be unpacked and used at runtime. It doesn't work automatically and it needs to be configured properly. If, for example, you were to add outlets and actions pointing to an instance of UIViewController instead of test (whose name should start with a capital letter) then you would get an exception at runtime when the archive is unpacked and it is found that the outlets can't be connected, because UIViewController doesn't define them.
YES, it is mandatory. In addition to other answers posted here, I would like to tell you to think over this thing:
Suppose you have more than one Class & ViewController in your demo
project, how do you expect XCode to assign proper Classes to specific
ViewControllers?

Unable to add an action to my controller from storyboard iOS

This has been asked before but as you can see from the picture a simple control+drag from the story board to the controller doesn't work. I made a new Cocoa Class subclass of UIViewController. After I try to hook up my Map View to it and it simply does not respond.
You have most likely not set your View Controller's class to your newly created class.
You can do this by going to your View Controller's Identity Inspector and changing the class from UIViewController to MapViewController.
You'll then be able to connect UI elements.
You might have forgotten to set the class of the view controller you have in the storyboard. Make sure the class is set to "MapViewController"
Here is where you set it :
Setting the Class of a VC in Storyboard
It's your own issue.
1) Storyboard on left side
2) class(ViewController) should be automatic in right side.
See image below:

How do I associate a Storyboard UIViewController with my custom UIViewController class?

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.
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.
As the error message says, custom classes are now forbidden in Launch Screens in Xcode 7. See e.g. here as well
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).
You can set a custom class to any storyboard component except the launchscreen.xib file.
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.

Can't set view outlet in xib

I have a xib file that includes a view controller but I have the same problem as this link: problem
In this answer they can easily set outlet because view has a circle that is clickable.But in my case the view outlet is not even clickable.So I can't set the outlet.What to do now?
The correct way to use initWithNibName:: is to have a "View" IB document where you have the desired VC view outlet as a root element. You need to set the "File's Owner" "Class" to your UIViewController subclass and connect it's view outlet:
Also, don't present modal VC from self at viewDidLoad: at the time of this method execution the VC is often not yet presented itself, viewDidAppear: is more fitting for such tests.
I had this same problem, but neither this nor any other solutions seemed to work - what I wound up doing was setting the custom class to UIViewController, linking the view as described in the question link, and then changing the class back to the actual custom class name I had intended. The link stayed and everything worked from that point on.

Can't set custom class name

I can't seem to be able to set the identity of my view to GraphViewController in Xcode 4.2.
I dragged a regular UIView in storyboard on a UIScrollView.
I create a new file called GraphViewController extending UIViewController (.h and .m) but when I click on my view in storyboard and try to set the custom class name (its identity) to GraphViewController, it doesn't set it. It doesn't even show it in the dropdown list.
Am I missing something here a connection or something?
You can set any class inherited from UIView to a UIView instance.
But you have created a UIViewController subclass, not a UIView subclass.
You can assign your custom class to the controller, not to the view.
In case anyone ever makes the dumb mistake I just did... ensure you have created an appropriate storyboard for either iOS or OS X. Adding the wrong one to your project will certainly cause issues like this.
My solution was making sure I was clicking on the controller's top tool bar, and not the "screen" UI frame. If you select the frame or anything in it, your Identity Inspector will be looking at the View, or other elements in the storyboard, instead of the controller itself.

Resources