1 創(chuàng)建自定義引導(dǎo)界面缘薛,繼承Uiview
2 在.m 文件中添加方法,并在.h文件中聲明埃儿,判斷是否時第一次打開軟件并執(zhí)行相關(guān)操作
NSString *key = @"CFBundleShortVersionString";
+ (void)show {
NSString *key = @"CFBundleShortVersionString";
// 獲得當(dāng)前軟件的版本號
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
// 獲得沙盒中存儲的版本號
NSString *sanboxVersion = [[NSUserDefaults standardUserDefaults] stringForKey:key];
if (![currentVersion isEqualToString:sanboxVersion]) {
UIWindow *window = [UIApplication sharedApplication].keyWindow;
// 自定義引導(dǎo)界面
KLPushGuideView *guideView = [KLPushGuideView pushGuideView];
guideView.frame = window.bounds;
[window addSubview:guideView];
// 存儲版本號
[[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
// 立即存儲
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
- 加載引導(dǎo)界面器仗,當(dāng)引導(dǎo)界面顯示之后, 點(diǎn)擊上面的確定(或 "知道了")童番,執(zhí)行的dismiss事件
// 從XIB中加載視圖
+ (instancetype)pushGuideView {
return [[NSBundle mainBundle] loadNibNamed:@"KLPushGuideView" owner:nil options:nil].lastObject;
}
// 點(diǎn)擊事件
- (IBAction)dismiss:(id)sender {
[self removeFromSuperview];
}
- 在 Applegation.m 文件中 調(diào)用 在自定義界面的.h文件中所聲明的方法
// 顯示推送引導(dǎo)
[KLPushGuideView show];