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]];

        }

    }

  • 相关阅读:
    将word转化为swf 进行如同百度文库的般阅读
    最大子数组问题——编程珠玑第八章
    为什么静态成员必须在类外初始化
    C++初始化列表
    异步消息总线hornetq学习-03客户端连接hornet进行jms消息的收发-非jndi方式连接
    [PLL][PM]锁相环模拟相位解调
    insertion sort
    SRM 581 D2 L2:SurveillanceSystem,重叠度
    JQuery(下)
    Ajax
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5207417.html
Copyright © 2011-2022 走看看