设为首页 加入收藏

TOP

在进入新版本 的时候,进行推送引导
2017-10-13 10:28:33 】 浏览:6336
Tags:进入 版本 时候 进行 推送 引导

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;
}
 
 
 
 
 
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇创建Podspec 并且发布到github sp.. 下一篇lable计算行高

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目