zoukankan      html  css  js  c++  java
  • 网络检测,版本更新

    要导入的头文件

    #import "Reachability.h"

    网络检测代码段 

        BOOL isExistenceNetwork;

    Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];

        switch ([r currentReachabilityStatus]) {

            case NotReachable:

    isExistenceNetwork=FALSE;

                break;

            case ReachableViaWWAN:

    isExistenceNetwork=TRUE;

                break;

            case ReachableViaWiFi:

    isExistenceNetwork=TRUE;

                break;

        }

    if (!isExistenceNetwork) {

    UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:@"网络连接不佳" message:@"请检查网络连接,并重启程序"delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil,nil];

            myalert.delegate = self;

            myalert.tag = 2;

    [myalert show];

    [myalert release];

            return YES;

            

    }

    版本检测代码段

    if(AppVersion < version){

                NSString *prompt = [NSString stringWithFormat:@"IBMUnixWorld已更新到%1.1f版本",version];

                UIAlertView *av=[[[UIAlertView alloc] initWithTitle:@"版本更新" message:prompt delegate:selfcancelButtonTitle:@"否" otherButtonTitles:@"是", nil] autorelease];

                av.tag = 1;

                [av show];

            }

    //alertViewDelegate

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

        //NSLog(@"clickedButtonAtIndex %d",buttonIndex);

        if(alertView.tag == 1){

            if(buttonIndex == 1){

                NSLog(@"appStoreLinkURL %@",appStoreLinkURL);

                NSString *appURL = appStoreLinkURL;

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

            }

        }else if(alertView.tag == 2){

            exit(1);

        }

    }

  • 相关阅读:
    【FLASH BUILDER 4.6 快捷键】只记几个对自己有帮助的
    分享一个消息组件
    一些iis配置相关报错的参考
    JQuery 学习总结及实例
    百度地图 测距
    VS2010引用App_Code下的类文件问题解决方法
    HttpWebRequest 方式提交文件数据以图片为例
    Flex与.NET互操作(二):基于WebService的数据访问(上)
    Asp.net MVC中的ViewData与ViewBag
    C# HttpWebRequest 方式提交数据,参数为普通键值对
  • 原文地址:https://www.cnblogs.com/q403154749/p/3928058.html
Copyright © 2011-2022 走看看