开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜