开发者

How to only display a message once on app start up?

开发者 https://www.devze.com 2023-02-19 19:26 出处:网络
How would i display a UIImageView only when my app is first开发者_开发技巧 started ?Use NSUserDefaults to set a BOOL flag like \"firstStart\" to YES/NO and read that value on applicationDidFinishLaunc

How would i display a UIImageView only when my app is first开发者_开发技巧 started ?


Use NSUserDefaults to set a BOOL flag like "firstStart" to YES/NO and read that value on applicationDidFinishLaunch:.

If YES, run your first message method and if NO continue with a normal run.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]
if ([defaults boolForKey:@"firstStart"] == YES)
{
      [self firstStartMessage];
      [defaults setValue:NO forKey:@"firstStart"];
}


Once, the first time the app is started on the device? Set a flag in NSUserDefaults to indicate that the message has been shown already.

Once each time the app is started? Put a flag ivar in your app delegate or root view controller, or even use a global variable.

0

精彩评论

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