Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Launch Screen in Swift

Im curious if anyone knows how to extend the time of the Launch Screen to the first view. I believe it's set to 2 seconds. I'd like to make it longer. I heard some people connect the launch screen to the View controller then went into the AppDelegate, then edited the didFinishLaunchingWithOptions function. Not sure though.

Anyone have experience with this?

3 Answers

Pasan Premaratne
STAFF
Pasan Premaratne
Treehouse Teacher

Like Patrick says, a solution that is recommended often is to use a sleep timer to prevent the app from launching immediately. However, blocking the main thread not a good idea because it'll give users the impression that their phone/your app is frozen since touches are handled on the main thread.

A less often recommended but safer solution is to present a modal screen with a timer. This gives the impression that you're still on the launch screen but has the side effect of not blocking the app.

All that said, Apple does state this in the Human Interface Guidelines:

As much as possible, avoid displaying a splash screen or other startup experience. It’s best when users can begin using your app immediately.

Patrick Cooney
Patrick Cooney
12,216 Points

Thanks for chiming in. I knew there had to be a better answer than blocking all actions on the main thread.

Patrick Cooney
Patrick Cooney
12,216 Points

If you just want the launch screen to show a little bit longer you can use an NSThread sleep timer. Be aware, this is a blocking call. No other tasks will be able to run while this is going on. I used this in my app to keep the launch screen up for 3 seconds. Maybe Amit Bijlani or Pasan Premaratne have a better way?

Thanks to both of you! I'll try both but probably go with the latter to Pasan's suggestion.

Thanks Again!