Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show screen on first launch only in iOS

Tweetbot and Clear show's on the first start of the app a small tutorial screen how the app works. The screen with the small tutorial only pops up on the first start up of the app (1 time)

How and with what can i make a similar thing? Can anyone push me in the right direction?

View i mean:

enter image description here

like image 577
Frenck Avatar asked Feb 26 '12 03:02

Frenck


People also ask

How do I know when I first launch iOS app?

Then you just need to call the function setFirstAppLaunch() at the start of your application and isFirstAppLaunch() whenever you want to check if your app has been called.

What is iOS launch screen?

Every iOS app must provide a launch screen, a screen that displays while your app launches. The launch screen appears instantly when your app starts up and is quickly replaced with the app's first screen.


1 Answers

I'm assuming by Xcode you actually mean iOS.

What you need to do is use the NSUserDefaults class to store a flag indicating whether the user has seen the tutorial screen before.

When your app first loads (or at the point you want to decide whether or not to show the tutorial screen), do something like this:

if(![[NSUserDefaults standardUserDefaults] boolForKey:@"hasSeenTutorial"])     [self displayTutorial]; 

This checks the saved NSUserDefaults for the current user for a value named "hasSeenTutorial", which won't exist yet. Since it doesn't exist, it will call displayTutorial. displayTutorial refers to your method for creating the tutorial view. You can figure out that part.

Then, once the user closes the tutorial screen:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasSeenTutorial"]; 

That value will be saved for your user profile, meaning the next time it checks it, it will be true, so displayTutorial won't be called.

like image 142
chroipahtz Avatar answered Oct 08 '22 12:10

chroipahtz