在进入新版本 的时候,进行推送引导
生活随笔
收集整理的這篇文章主要介紹了
在进入新版本 的时候,进行推送引导
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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; }
轉載于:https://www.cnblogs.com/qianLL/p/5529637.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的在进入新版本 的时候,进行推送引导的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql查看数据库命令
- 下一篇: 《构建之法》8.9.10