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.
精彩评论