zoukankan      html  css  js  c++  java
  • 2016-02-22 版本更新

    • didfinishlauch  appdelegate 中

       

        // 01  gzz022 版本更新 

        [self VersionButton];

        

    //02    gzz0222 提示自动更新

    -(void)VersionButton{

        NSString  *string=[NSString stringWithContentsOfURL:[NSURL URLWithString:@"https://itunes.apple.com/lookup?id=1079728205"] encoding:NSUTF8StringEncoding error:nil];

        if (string!=nil &&[string length]>0&&[string rangeOfString:@"version"].length==7 ) {

            [self checkUpAppUpdate:string];

        }

       

    }

    //03   gzz0222

    -(void)checkUpAppUpdate:(NSString *)appInfo{

     //获取当前版本

    //    NSString *version=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];//CFBundleShortVersionString

        

        NSString *version=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];//CFBundleShortVersionString

        NSString  *appInfo1=[appInfo substringFromIndex:[appInfo rangeOfString:@""version":"].location+10];

        

        appInfo1=[[appInfo1 substringToIndex:[appInfo1 rangeOfString:@","].location]stringByReplacingOccurrencesOfString:@""" withString:@""];

        

        //判断,如果当前版本与发布的版本不相同,则进入更新.如果相等,那么当前版本就是最新版本

        

    //    NSString *ver2=@"2.0";

        

        if (![appInfo1 isEqualToString:version]) {

            NSLog(@"%@ 新版本,%@当前版本",appInfo1,version);

            UIAlertView  *alert=[[UIAlertView alloc]initWithTitle:@"" message:[NSString stringWithFormat:@"新版本 %@ 已发布!",appInfo1] delegate:self.class cancelButtonTitle:@"稍后更新" otherButtonTitles:nil, nil];

            alert.delegate=self;

            [alert addButtonWithTitle:@"前往更新"];

            [alert show];

            

            alert.tag=20019;

            

        }else{

    //       UIAlertView  *alll= [[UIAlertView  alloc]initWithTitle:nil message:@"已是最高版本!" delegate:self.class cancelButtonTitle:@"知道啦!" otherButtonTitles:nil ,nil];

    //

    //        [alll show];

        

        }

    }

    //alertview代理 

    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

        if (alertView.tag==20019&&buttonIndex==1) {

            NSString  *strUrl=[NSString stringWithFormat:@"https://itunes.apple.com/cn/app/gan-dan-xiang-zhao/id1079728205?mt=8"];

            

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:strUrl]];

        }

    }

  • 相关阅读:
    【OpenCV】SIFT原理与源码分析:方向赋值
    【OpenCV】SIFT原理与源码分析:关键点搜索与定位
    【OpenCV】SIFT原理与源码分析:DoG尺度空间构造
    【OpenCV】SIFT原理与源码分析
    在Android 下写一个检测软件版本号 以自动升级APP 的插件
    Android开发-eclipse+phonegap(Cordova)环境搭建
    phonegap(cordova)从手机app跳转到web页面在跳转回APP本地页面思路
    黑板客爬虫闯关第一关、第二关
    scrapy实战
    scrapy爬虫框架
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5207417.html
Copyright © 2011-2022 走看看