最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

IOS代碼筆記之網(wǎng)絡(luò)嗅探功能

 更新時(shí)間:2016年07月06日 10:21:30   作者:情深雨蒙  
這篇文章主要為大家詳細(xì)介紹了IOS網(wǎng)絡(luò)嗅探功能實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了IOS網(wǎng)絡(luò)嗅探工具,供大家參考,具體內(nèi)容如下

一、效果圖 

二、工程圖

 

三、代碼
AppDelegate.h

#import <UIKit/UIKit.h>
#import "Reachability.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
   Reachability *reachability;
   BOOL WarningViaWWAN;
}

@property (strong, nonatomic) UIWindow *window;


- (void)ReachabilitySniff:(Reachability*) curReach;
- (void)ReachabilitySniffNotification:(NSNotification* )notification;
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;

@end 

AppDelegate.m

#import "AppDelegate.h"
#import "RootViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  // Override point for customization after application launch.
  
  RootViewController *rootVC=[[RootViewController alloc]init];
  UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:rootVC];
  self.window.rootViewController=nav;
  
  
  //啟動(dòng)網(wǎng)絡(luò)嗅探功能
  WarningViaWWAN = TRUE;
  
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ReachabilitySniffNotification:) name:kReachabilityChangedNotification object:nil];
  
  if (!reachability) {
    reachability = [Reachability reachabilityForInternetConnection];
  }
  [reachability startNotifier];
  
  [self performSelector:@selector(ReachabilitySniff:) withObject:reachability afterDelay:20];

  
  
  
  self.window.backgroundColor = [UIColor whiteColor];
  [self.window makeKeyAndVisible];
  return YES;
}
#pragma mark -網(wǎng)絡(luò)嗅探
- (void)ReachabilitySniffNotification:(NSNotification* )notification
{
  Reachability* curReach = [notification object];
  [self performSelector:@selector(ReachabilitySniff:) withObject:curReach afterDelay:2];
}

- (void)ReachabilitySniff:(Reachability*) curReach
{
  NSLog(@"ReachabilitySniffNewWorkStatus");
  if (!curReach) {
    return;
  }
  NetworkStatus status = [curReach currentReachabilityStatus];
  switch (status) {
    case ReachableViaWiFi:
    {
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"您正在使用WiFi網(wǎng)絡(luò)" message:Nil delegate:self cancelButtonTitle:Nil otherButtonTitles:@"本次不再提醒",@"知道了", nil];
      [alert show];
      break;
    }
    case ReachableViaWWAN:
    {
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"您正在使用移動(dòng)網(wǎng)絡(luò),運(yùn)營商會(huì)收取流量費(fèi),建議使用WiFi網(wǎng)絡(luò)" message:Nil delegate:self cancelButtonTitle:Nil otherButtonTitles:@"本次不再提醒",@"知道了", nil];
        [alert show];
       break;
    }
    case NotReachable:
    {
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"沒有網(wǎng)絡(luò)" message:Nil delegate:self cancelButtonTitle:Nil otherButtonTitles:@"本次不再提醒",@"知道了", nil];
      [alert show];
      break;
    }
  }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 簡(jiǎn)單掌握iOS應(yīng)用開發(fā)中sandbox沙盒的使用

    簡(jiǎn)單掌握iOS應(yīng)用開發(fā)中sandbox沙盒的使用

    這篇文章主要介紹了iOS應(yīng)用開發(fā)中sandbox沙盒的使用,即將應(yīng)用的存儲(chǔ)區(qū)域單獨(dú)隔離開來,開發(fā)時(shí)經(jīng)??梢杂玫?需要的朋友可以參考下
    2016-01-01
  • MAUI模仿iOS多任務(wù)切換卡片滑動(dòng)的交互實(shí)現(xiàn)代碼

    MAUI模仿iOS多任務(wù)切換卡片滑動(dòng)的交互實(shí)現(xiàn)代碼

    這篇文章主要介紹了[MAUI]模仿iOS多任務(wù)切換卡片滑動(dòng)的交互實(shí)現(xiàn),使用.NET MAU實(shí)現(xiàn)跨平臺(tái)支持,本項(xiàng)目可運(yùn)行于Android、iOS平臺(tái),需要的朋友可以參考下
    2023-05-05
  • 詳解Objective C 中Block如何捕獲外部值

    詳解Objective C 中Block如何捕獲外部值

    這篇文章主要為大家介紹了詳解Objective C 中Block如何捕獲外部值實(shí)現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • IOS實(shí)現(xiàn)百度地圖自定義大頭針和氣泡樣式

    IOS實(shí)現(xiàn)百度地圖自定義大頭針和氣泡樣式

    這篇文章主要介紹了 IOS百度地圖自定義大頭針和氣泡的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下
    2016-12-12
  • iOS實(shí)現(xiàn)轉(zhuǎn)盤效果

    iOS實(shí)現(xiàn)轉(zhuǎn)盤效果

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)轉(zhuǎn)盤效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • iOS開發(fā)之觸摸事件以及手勢(shì)

    iOS開發(fā)之觸摸事件以及手勢(shì)

    這篇文章主要為大家詳細(xì)介紹了iOS開發(fā)之觸摸事件以及手勢(shì)的相關(guān)資料,感興趣的小伙伴們可以參考一下
    2016-04-04
  • iOS 中KVC、KVO、NSNotification、delegate 總結(jié)及區(qū)別

    iOS 中KVC、KVO、NSNotification、delegate 總結(jié)及區(qū)別

    這篇文章主要介紹了iOS 中KVC、KVO、NSNotification、delegate 總結(jié)及區(qū)別的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • 簡(jiǎn)單說說iOS之WKWebView的用法小結(jié)

    簡(jiǎn)單說說iOS之WKWebView的用法小結(jié)

    iOS8.0之后我們使用 WebKit框架中的WKWebView來加載網(wǎng)頁。這篇文章主要介紹了簡(jiǎn)單說說iOS之WKWebView的用法小結(jié),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-01-01
  • iOS中的類、元類以及isa示例詳解

    iOS中的類、元類以及isa示例詳解

    從初學(xué)OC的時(shí)候就聽人提起過OC對(duì)象中的isa指針,用來指向?qū)ο笏鶎俚念悾瑥亩梢栽谡{(diào)用方法時(shí)通過isa指針找到相應(yīng)的方法和屬性,下面這篇文章主要給大家介紹了關(guān)于iOS中類、元類以及isa的相關(guān)資料,需要的朋友可以參考借鑒,下面來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-01-01
  • Flutter Widgets MediaQuery控件屏幕信息適配

    Flutter Widgets MediaQuery控件屏幕信息適配

    這篇文章主要為大家介紹了Flutter Widgets 之 MediaQuery控件獲取屏幕信息和屏幕適配示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-11-11

最新評(píng)論

无为县| 罗城| 满洲里市| 方城县| 武安市| 阳曲县| 永定县| 元阳县| 嘉峪关市| 明溪县| 张家港市| 会东县| 炉霍县| 永吉县| 安平县| 丽水市| 巫溪县| 巴彦淖尔市| 泊头市| 兴业县| 邢台市| 长治市| 库尔勒市| 洛南县| 河津市| 华容县| 青岛市| 本溪市| 柏乡县| 尤溪县| 黔西| 巴东县| 平塘县| 溧阳市| 玉树县| 剑阁县| 丰县| 腾冲县| 阳谷县| 航空| 本溪市|