判断引导页首次出现方式:

//选择根控制器
+(void)chooseRootViewController{ //初始化Window窗口
[AppDelegate Delegate].window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[AppDelegate Delegate].window.backgroundColor = [UIColor whiteColor];
[[AppDelegate Delegate].window makeKeyAndVisible]; //取出沙盒中存储的上次使用软件的版本号
    NSString *key = @"CFBundleVersion";
    NSString *lastVersion = [defaluts stringForKey:key];

    //获取当前软件的版本号
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
if ([currentVersion isEqualToString:lastVersion]) {
if ([ToolManager maitchWithAccountNumAndPassword] && [ToolManager IsOrNoAutoLogin]== YES) {
//登录成功,进入主控制器
[AppDelegate Delegate].window.rootViewController = [[KJTabViewController alloc]init];
}else{
//用户已经注册过,进入登陆控制器
[self setLoginVC];
}
}else{ //用户初次使用,进入引导页控制器
[AppDelegate Delegate].window.rootViewController = [[KJGuidePageController alloc]init]; //存储新的版本号
[defaluts setObject:currentVersion forKey:key];
[defaluts synchronize];
}
}

版本更新方式:http://www.cnblogs.com/jys509/p/5390505.html

1.获取当前项目APP版本号

2.拿到AppStore项目版本号

3.对比版本号,实现更新功能

第一种方式:

/**
* 检测app更新
*/
-(void)hsUpdateApp
{
//1.先获取当前工程项目版本号
NSDictionary *infoDic=[[NSBundle mainBundle] infoDictionary];
NSString *currentVersion=infoDic[@"CFBundleShortVersionString"]; //2.从网络获取appStore版本号
NSError *error;
NSData *response = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%@",STOREAPPID]]] returningResponse:nil error:nil];
if (response == nil) {
NSLog(@"你没有连接网络哦");
return;
}
NSDictionary *appInfoDic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
if (error) {
NSLog(@"hsUpdateAppError:%@",error);
return;
}
NSArray *array = appInfoDic[@"results"];
NSDictionary *dic = array[];
NSString *appStoreVersion = dic[@"version"];
//3.打印版本号
NSLog(@"当前版本号:%@\n商店版本号:%@",currentVersion,appStoreVersion);
//4当前版本号小于商店版本号,就更新
if([currentVersion floatValue] < [appStoreVersion floatValue])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"版本有更新" message:[NSString stringWithFormat:@"检测到新版本(%@),是否更新?",appStoreVersion] delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"更新",nil];
[alert show];
}else{
NSLog(@"版本号好像比商店大噢!检测到不需要更新");
}
} - (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//5.实现跳转到应用商店进行更新
if(buttonIndex==)
{
//6.此处加入应用在app store的地址,方便用户去更新,一种实现方式如下:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/id%@?ls=1&mt=8", STOREAPPID]];
[[UIApplication sharedApplication] openURL:url];
}
}

第二种方式:

#pragma mark - 版本判断
/**
* 专用检测app更新
*/
-(void)judgeVersionUpdate
{
NSString *urlStr = [NSString stringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%@",STOREAPPID];
NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[NSURLConnection connectionWithRequest:req delegate:self];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
NSError *error;
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
NSDictionary *appInfo = (NSDictionary *)jsonObject;
NSArray *infoContent = [appInfo objectForKey:@"results"];
NSString *appStoreVersion = [[infoContent objectAtIndex:] objectForKey:@"version"];
KJLog(@"商店的版本是:%@",appStoreVersion); NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
KJLog(@"当前的版本是:%@",currentVersion);
if (![appStoreVersion isEqualToString:currentVersion]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"版本有更新" message:[NSString stringWithFormat:@"检测到新版本(%@),是否更新?",appStoreVersion] delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"更新",nil];
[alert show];
}
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==)
{
//此处加入应用在app store的地址,方便用户去更新
NSString *iTunesLink = [NSString stringWithFormat:@"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=%@&mt=8",STOREAPPID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}
}

iOS:判断引导页首次出现、版本更新的更多相关文章

  1. iOS App引导页功能实现

    一.写作原因 以前都没有想着来写点东西,今天遇到件事情让我决定每次还是要做记录.因为以前自己可以轻松的完成pod spec的配置,但是今天在做的时候还是忘了遇到了很多坑.pod spec配置遇到的坑不 ...

  2. [iOS] App引导页的简单实现 (Swift 2)

    转载请注明出处:http://www.jianshu.com/p/024dd2d6e6e6# 已更新至 Xcode7.2.Swift2.1 在第一次打开App或者App更新后通常用引导页来展示产品特性 ...

  3. ios开发-引导页实现

    源码:http://files.cnblogs.com/ios8/%5Bcode4app.com%5DIntroductionTutorialView_10843.zip 可以看看demo,很简单,我 ...

  4. iOS透明引导页

    一.效果展示 这里写图片描述 这种类型的新手引导比较常见,用于告诉用户某个按钮的作用,或者提醒用户可以进行某种交互操作.引导样式是在界面上加了一个半透明的引导图,高亮部分就是要突出的区域 二.怎么做? ...

  5. IOS 一句代码搞定启动引导页

    前言引导页,一个酷炫的页面,自从微博用了之后一下就火起来了,对于现在来说一个app如果没有引导页似乎总显那么不接地气,那么为了让我们的app也“高大上”一次,我写了一个demo来实现启动引导页的实现, ...

  6. iOS - GitHub干货分享(APP引导页的高度集成 - DHGuidePageHUD - ②)

    距上一篇博客"APP引导页的高度集成 - DHGuidePageHUD - ①"的发布有一段时间了, 后来又在SDK中补充了一些新的内容进去但是一直没来得及跟大家分享, 今天来跟大 ...

  7. IOS引导页拨动4张图片最后一张停三秒进入主页,页面推送

    // //  ViewController.m // // //  Created by 张艳锋 on 15/8/26. //  Copyright (c) 2015年 张艳锋. All rights ...

  8. Sagit.Framework For IOS 开发框架入门教程3:Start引导页及框架布局和隐藏事件的内幕

    前言: 框架依旧在快速更新着:在重构.简化代码,统一标准的过程中. 中间也遇到各种坑,不过好在一步一脚印的解决了. 虽然还有些功能还在思考,不过教程,还是得补上: 上篇文章:Sagit.Framewo ...

  9. iOS - GitHub干货分享(APP引导页的高度集成 - DHGuidePageHUD - ①)

    好长时间没更新博客, 是时候来一波干货分享了;APP引导页话不多说每一个APP都会用到,分量不重但是不可缺少,不论是APP的首次安装还是版本的更新,首先展现给用户眼前的也就只有它了吧,当然这里讲的不是 ...

随机推荐

  1. 快速开发window服务器程序

    import service; service.startDispatchThread( 服务名 = function(serviceName,argv){ import service; var s ...

  2. centos使用boost过程

    1. 安装gcc,g++,make等开发环境 yum groupinstall "Development Tools" 2. 安装boost  yum install boost ...

  3. c++ 容器学习 理论

    [转载]http://blog.csdn.net/acosoft/article/details/4395468 在面向对象的语言中,大多引入了容器的概念.那么 什么 是 容器?实质上就是一组相同类型 ...

  4. 自定义mvc验证特性,手机号号段老增加,给自定义一个RegularExpress

    public class PhoneExpressionAttribute: RegularExpressionAttribute, IClientValidatable { public Phone ...

  5. php源码审计

    转:http://www.jb51.net/article/31898.htm 针对PHP的网站主要存在下面几种攻击方式: 1.命令注入(Command Injection) 2.eval注入(Eva ...

  6. powershell 获取 CPU 物理 / 逻辑核心数

    转载请注明: 仰望高端玩家的小清新 http://www.cnblogs.com/luruiyuan/   获取 CPU 逻辑核心数的方法为:总逻辑核心数 = 物理核心数 * 每核逻辑核心数   其中 ...

  7. 湖南大学ACM程序设计新生杯大赛(同步赛)G - The heap of socks

    题目描述 BSD is a lazy boy. He doesn't want to wash his socks, but he will have a data structure called ...

  8. BNUOJ 52506 Captcha Cracker

    简单模拟题. #include<bits/stdc++.h> using namespace std; ]; int T; int main() { scanf("%d" ...

  9. iOS 9音频应用播放音频之音量设置与声道设置

    iOS 9音频应用播放音频之音量设置与声道设置 iOS 9音频应用音量设置 音量又称响度.音强,是指人耳对所听到的声音大小强弱的主观感受,其客观评价尺度是声音的振幅大小.在iOS 9音频应用的应用中, ...

  10. Highcharts实现走势图

    Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是web应用程序添加有交互性的图表,并且免费提供给个人学习.个人网站和非商业用途使用.HighCh ...