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
  • 相关阅读:
    Mysql推荐使用规范
    程序员应该经常浏览的技术网站
    百度,腾讯,阿里等互联网公司年终奖发多少
    JNI技术详解,让程序有飞一般的感觉
    日志:分布式系统的核心
    Spring Boot七:Spring boot集成MyBatis
    通俗理解TCP的三次握手
    JDBC添加数据
    JDBC概念
    今天是阳光明媚的一天
  • 原文地址:https://www.cnblogs.com/hero11223/p/5587221.html
Copyright © 2011-2022 走看看