zoukankan      html  css  js  c++  java
  • 在进入新版本 的时候,进行推送引导

    xx效果

    具体代码如下
    首先新建XMGPushGuideView类
     
    XMGPushGuideView.h 文件
     
    #import <UIKit/UIKit.h>

    @interface XMGPushGuideView : UIView
    /** 加载xib */
    +(instancetype)guideView;
    /** 判断当前的版本号,确定是加载推荐引导页 */
    +(void)show;
    @end
     
     
     
    XMGPushGuideView.m 文件
     
    #import "XMGPushGuideView.h"

    @implementation XMGPushGuideView

    +(instancetype)guideView{

        return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
    }
    - (IBAction)close {
        [self removeFromSuperview];
    }

    +(void)show{
       
        NSString *key=@"CFBundleShortVersionString";
       
        // 获得当前软件的版本号
        NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
       
        //    获得沙盒中的存储的版本号
        NSString *sanboxVersion=[[NSUserDefaults standardUserDefaults] stringForKey:key];
       
        if (![currentVersion isEqualToString:sanboxVersion]) {
           
    //        获得当前的window
            UIWindow *window=[UIApplication sharedApplication].keyWindow;

           
            XMGPushGuideView *guideView=[XMGPushGuideView guideView];
            guideView.frame=window.bounds;
            [window addSubview:guideView];
            //        存储版本号
            [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
            //       马上把版本号存储到沙盒中
            [[NSUserDefaults standardUserDefaults] synchronize];
        }
       
    }
    @end
     
     
    而在AppDelegate.m文件
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
       
    //    创建窗口
        self.window=[[UIWindow alloc]init];
        self.window.frame=[UIScreen mainScreen].bounds;
       
    //    设置窗口的跟控制器
         self.window.rootViewController=[[XMGTabBarController alloc]init];

       
    //    显示窗口
        [self.window makeKeyAndVisible];
       


    //    显示推送引导
        [XMGPushGuideView show];
       
       
        return YES;
    }
     
     
     
     
     
  • 相关阅读:
    [每日一讲] Python系列:浅拷贝与深拷贝
    [每日一讲] Python系列:变量、内存管理与传递
    [每日一讲] Python系列:字典
    [每日一讲] Python系列:列表与元组
    [已开源/文章教程]独立开发 一个社交 APP 的源码/架构分享 (已上架)
    从选择到上传,可能是最贴心的高仿朋友圈编辑了
    完整的社交app源码android+laravel
    基于Laravel+Swoole开发智能家居后端
    APP架子迁移指南(三)
    Laravel如何优雅的使用Swoole
  • 原文地址:https://www.cnblogs.com/qianLL/p/5529637.html
Copyright © 2011-2022 走看看