- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//在appdelegate.m中的 “application:didFinishLaunchingWithOptions:” 方法, 添加以下代码:
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"nofirst"]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"nofirst"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLogin"];
}
else{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLogin"];
}
// 总的解决办法是 2 个key: @”nofirst”判断用户以前是否登录,
// @”firstLogin” 用来开发者在程序的其他部分判断.
// 在第一次启动的时候 key @”nofirst” 不会被赋址的, 并且设置为YES. @”firstLogin” 被设置为 YES.
// 在程序的其他部分用以下代码判断:
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLogin"]) {
// 这里判断是否第一次
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"第一次"
message:@"进入App"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
return YES;
}
转载请注明出处:http://blog.csdn.net/sevenquan