根据网络状态判断是否打开程序
来源:互联网 发布:山下智久退出news 知乎 编辑:程序博客网 时间:2024/04/29 11:04
//
// AppDelegate+Reachability.h
//
//
// Created by Floating_SH on 16/1/20.
// Copyright © 2016年 K_night. All rights reserved.
//
#import "AppDelegate.h"
@class Reachability;
@interface AppDelegate (Reachability)
- (void) judgeNetework;
@end
//
// AppDelegate+Reachability.m
//
//
// Created by Floating_SH on 16/1/20.
// Copyright © 2016年 K_night. All rights reserved.
//
#import "AppDelegate+Reachability.h"
#import "Reachability.h"
@implementation AppDelegate (Reachability)
- (void)judgeNetework{
Reachability *reachability = [ReachabilityreachabilityForInternetConnection];
if (reachability.currentReachabilityStatus ==NotReachable) {
UIAlertController *successdController = [UIAlertControlleralertControllerWithTitle:@"提示"message:@"网络无连接,无法信息,请检查网络连接后运行程序"preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *defultAction = [UIAlertActionactionWithTitle:@"确认"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction *_Nonnull action) {
NSLog(@"无网络");
[self exitApplication];
}];
[successdController addAction:defultAction];
[self.window.rootViewControllerpresentViewController:successdController animated:YEScompletion:nil];
}elseif (reachability.currentReachabilityStatus ==ReachableViaWiFi){
NSLog(@"当前网络状态为WIFI");
}else{
NSLog(@"当前网络为WWAN");
}
//开启向通知中心发送网络状态改变后的通知
// [reachability startNotifier];
}
//------------------ 退出程序 ---------------------
- (void)exitApplication {
[UIView beginAnimations:@"exitApplication"context:nil];
self.tab.tabBar.hidden = YES;
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:(UIViewAnimationTransitionNone)forView:self.windowcache:NO];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
self.window.bounds =CGRectMake(0,0, 0, 0);
[UIView commitAnimations];
}
- (void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([animationID compare:@"exitApplication"] == 0) {
exit(0);
}
}
@end
- 根据网络状态判断是否打开程序
- 网络判断是否打开
- 判断网络状态是否可用
- 判断网络状态是否可用
- 判断程序是否已经打开
- 判断网络状态并打开网络设置
- 根据窗口句柄判断程序运行状态
- 根据进程名称判断程序是否运行
- ios - 测试网络状态是否连通 判断网络状态类型
- Android判断网络状态是否断开
- Android判断网络状态是否断开
- 如何判断网络是否进入拥塞状态
- Android如何判断网络状态是否良好
- Android判断网络状态是否可用的
- Android判断网络是否打开,并打开设置网络界面
- Android判断网络是否打开,并打开设置网络界面
- Android判断网络是否打开,并打开设置网络界面
- Android判断网络是否打开,并打开设置网络界面
- iOS性能优化---转载《一》iOS 异步图片加载优化与常用开源库分析
- 数据结构与算法
- 多线程模拟-爸爸放橙子给女儿吃,妈妈放苹果给儿子吃
- 蓝桥杯之 基础练习 字母图形
- js之内存泄漏
- 根据网络状态判断是否打开程序
- windows下如何使用软件来查看本机BIOS的类型
- Windows 窗体启动和关闭的事件顺序
- 关于个人的一些东西
- NOIP2015总结
- 一直忘记账号 github的账号也忘了 烦心
- 调用方法练习
- jquery 常用操作
- Hadoop YARN学习之Hadoop框架演进历史简述