zoukankan      html  css  js  c++  java
  • 判断app是否是第一次启动

    如何判断app是否是第一启动呢,第一次启动的时候,加载引导页面等,

    一下是我的解决方案:

    1、在"AppDelegate.h"中找到- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法,添加如下代码:

    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLaunch"];
    }
    总的解决办法是 2 个key: @”everLaunched”判断用户以前是否登录, 

    @”firstLaunch” 用来开发者在程序的其他部分判断.

    第一次启动的时候 key @”everLaunched” 不会被赋址的, 并且设置为YES. @”firstLaunch”被设置为 YES.

    在程序的其他部分用以下代码判断:
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) {
            // 这里判断是否第一次
            
            hDisplayView *hvc = [[hDisplayView alloc]initWithFrame:CGRectMake(0, 0, MainScreen_width, MainScreen_height)];
            
            [self.window.rootViewController.view addSubview:hvc];
            
            [UIView animateWithDuration:0.25 animations:^{
                hvc.frame = CGRectMake(0, 0, MainScreen_width, MainScreen_height);
                
            }];
            
        }
    第一段代码运行key 
    @”firstLaunch” 将被设置为 NO
  • 相关阅读:
    openpyxl(python操作Excel)
    python爬虫之数据加密解密
    python爬虫之字体反爬
    识别缩略图加载
    Windows文件共享自动失效解决办法
    pygame
    获取文件路径、文件名、后缀名
    Oracle EBS INV 挑库发放物料搬运单
    Oracle EBS INV 删除保留
    Oracle EBS INV 创建货位
  • 原文地址:https://www.cnblogs.com/hero11223/p/5587221.html
Copyright © 2011-2022 走看看