开发者

How do I make a welcome screen in my iPhone app?

开发者 https://www.devze.com 2023-03-12 18:41 出处:网络
I want to add a screen to my app that will be only displayed the first time when the开发者_高级运维 app is launched. How do I do that?

I want to add a screen to my app that will be only displayed the first time when the开发者_高级运维 app is launched. How do I do that? Thanks in advance. Cheers, Alex


You can keep a variable in NSUserDefaults. In your first view controller's viewDidLoad method check that variable and create the welcome screen and add it as a subview to the controller's view. Once its displayed you set the variable to 1 in NSUserDefaults.

This will display that screen first time when it's launched. If app is deleted then the next install will have the NSUserDefaults value cleared off. I hope this helps you. If you dont get the documentation of NSUserDefaults, which is fairly simple, drop a comment and I will write up a piece of code for you.


If you want the code, here's what I use;

#define kAppHasRunBeforeKey @"appFirstTimeRun"
if (![[[NSUserDefaults standardUserDefaults] valueForKey:kAppHasRunBeforeKey] boolValue]) { 
    //put your welcome code here
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kAppHasRunBeforeKey];
}

That will ensure that the welcome code is only run the first time your app runs across this code. Put this in your main view controller's viewDidLoad method and add your own welcome code.


I think you are asking for splash screen-an image displayed at app start-up

Here is a nice tutorial about this:

iPhone Tutorial for Creating a Splash Screen

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号