7

I have created a new project in Xcode 7 using Swift. I noticed that the launch screen is stored in the storyboard file.

So I think if it could be customised by referring it to my CustomLauchScreenViewController. However, when I set the custom class name in LaunchScreen.storyboard, it throws an error:

Launch screens may not set custom classnames

So what is the best way to customize the LaunchScreen? I intend to use the LaunchScreen to load some data before launching the main screen.

Ilya
  • 4,583
  • 4
  • 26
  • 51
chipbk10
  • 5,783
  • 12
  • 49
  • 85
  • 1
    something like king games (Candy , Soda , Digger etc) use a image for splash (launch Image). When you have control load a VC which have your custom work (animations or secondary images) and finally load your application. – Blind Ninja Oct 02 '15 at 09:33

2 Answers2

11

That's not the purpose of the launch screen. What you can do however if have your first initial viewController 'act' as a launch screen. Just have it display the same image as the launch image and do what you need to do in there. Once you are done, move to your main viewController from there.

Robert J. Clegg
  • 7,231
  • 9
  • 47
  • 99
  • So, the launch screen is not used to prepare some default data before launching the main screen? If so, the term "launch screen" is quite useless. – chipbk10 Oct 02 '15 at 09:39
  • 2
    Well, to a sense it is; but not for our code, for Apple's own startup code. If we want to have our code do setup work before the main app starts; we need to do as I suggested above. – Robert J. Clegg Oct 02 '15 at 09:40
  • If so, I should delete all the generated files, attributes regarding the "launch screen" in my project. – chipbk10 Oct 02 '15 at 09:42
  • if they are there by default, then no, don't do that. If you put them there; fine go ahead. Just make sure you keep the launch images for the device you're supporting – Robert J. Clegg Oct 02 '15 at 09:43
2

The launch screen is shown before your app starts executing in order to provide a transition from the Springboard to your app while it is loading. According to Apple interface guidelines,

A launch file (or image) provides a simple placeholder image that iOS displays when your app starts up. The placeholder image gives users the impression that your app is fast and responsive because it appears instantly and is quickly replaced by the first screen of your app.

To achieve a transition, remove the class from LaunchScreen.storyboard and set it similar to 0% loading transition. Create a new controller in your Main.storyboard and set CustomLauchScreenViewController there and assign this as initial view controller. Set CustomLauchScreenViewController as your root view controller in your app delegate. When launch screen will be replaced by your this controller, transition is too smooth to feel any difference. After loading the data, change your root view controller to required View Controller.

Sahil Kapoor
  • 11,183
  • 13
  • 64
  • 87
  • I set the CustomLaunchScreenViewController in storyboard, and it causes error. If you take a read at Tander's answer, the launchscreen is not used to load data. If loading data takes longer than the time of the transition, what will happen? – chipbk10 Oct 02 '15 at 09:50
  • You can't set any class in LaunchScreen.storyboard. Set similar controller as initial view controller in Main.storyboard. I updated the answer. – Sahil Kapoor Oct 02 '15 at 09:58
  • if the launchscreen is just for a smooth transition, so I don't need it. I will create another UIViewController in storyboard for the setup thing before moving to the main viewcontroller. I will delete all redundant thing regarding "launchscreen". Thanks. – chipbk10 Oct 02 '15 at 10:10
  • 1
    Providing launch screen is required now. You can't skip it. – Sahil Kapoor Oct 02 '15 at 10:57
  • I've deleted it, and it runs well. – chipbk10 Oct 02 '15 at 11:15
  • What @SahilKapoor is saying is correct. If you don't provide launch images as per the Apple guidelines, they will reject the app when you submit it. Your app must have a launch screen, yes, its just an image but thats the way Apple want it. – Robert J. Clegg Oct 02 '15 at 11:34