每次版本更新都出现引导页

思路:

将info.plist里存储的app版本号与用户沙盒里的app版本号进行对比,不一样就显示

#import "DXYPushGuide.h"

@implementation DXYPushGuide

+ (instancetype)guideView {
    
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
}

- (IBAction)close:(id)sender {
    
    [self removeFromSuperview];
}

+ (void)show {
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    
    NSString *key = @"CFBundleShortVersionString";
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    NSString *sanBoxVersion = [[NSUserDefaults standardUserDefaults] stringForKey:key];
    if (![currentVersion isEqualToString:sanBoxVersion]) {
        DXYPushGuide *guideView = [DXYPushGuide guideView];
        guideView.frame = window.bounds;
        [window addSubview:guideView];
        
        /** 存储新的版本号 */
        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}


你可能感兴趣的:(项目总结)