Now a lot of apps are added to the opening of the boot page, when the user first opened the application when the presentation, to the user some use of the guidance and instructions, when the user opened the second time is not displayed.
To achieve this effect, you only need to persist a flag. But the problem is, when the app is upgraded, we want to be able to reopen the new boot page to tell the user something about the new version, so that a flag-abiding method cannot be implemented.
"One can't, so use more." ”
We give this flag the version number of the program, so that when the program is upgraded, because the version number is different, it will be judged to be the first time to open.
Add the code where the Guide page ends:
NSString *version = [[[NSBundle Mainbundle] infodictionary] Objectforkey: (nsstring*) Kcfbundleversionkey]; *flag = [NSString stringWithFormat:@ "isfirst_%@", version]; [[Nsuserdefaults Standarduserdefaults] Setobject:[nsnumber Numberwithbool:no] forkey:flag];
[[Nsuserdefaults standarduserdefaults] synchronize]; Immediate persistence-because the user terminates the program without saving
Add code where the program determines if the Guide page appears:
-(BOOL) isfirstopen{ = YES; *flag = [NSString stringWithFormat:@ "isfirst_%@", [[[NSBundle Mainbundle] infodictionary] Objectforkey: (nsstring*) Kcfbundleversionkey]]; *tmp = [[Nsuserdefaults standarduserdefaults] objectforkey:flag]; if (Nil! = tmp) {= [tmp boolvalue] ; } return result;}
iOS Dev-judge the first opening of a program and the application of an upgrade