IPhone连接测试:如何强制它失去连接? [英] IPhone Connectivity Testing: How do I force it to lose connection?

查看:152
本文介绍了IPhone连接测试:如何强制它失去连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我找不到互联网连接,苹果希望我给用户一个友好的道歉。使用可达性演示,这是很容易。我想进一步,监控连接丢失。这个演示有这个功能,但我不知道如何关闭我的连接,测试它是否工作。

Apple wants me to give the user a friendly apology if I can't find an internet connection. Using the Reachability Demo, this was easy enough. I want to take it a step further and monitor for a connection loss. The demo has this functionality, but I can't figure out how to shut my connection off to test if it works.

我如何去模拟损失

推荐答案

如果您在iPhone模拟器中开发,只需将计算机从互联网断开连接。如果您的计算机没有网络访问权限,iPhone模拟器也无效。

If you're developing in the iPhone Simulator, simply disconnect your computer from the internet. If your computer has no network access, neither does the iPhone Simulator.

要在设备上测试,您可以执行以下操作:

To test on the device, you can do the following:

首先,设置一个可用于测试的WiFi路由器。

First, setup a WiFi router that you can use for testing.

您可以在手机上开启飞行模式,然后重新开启WiFi。这将防止3G连接提供数据访问。

You can turn on Airplane mode on the phone, then turn WiFi back on. This will prevent the 3G connection from providing data access.

启动您的应用程序。现在,您可以直接断开WiFi路由器,以模拟连接断开。

Launch your application. Now you can simply disconnect your WiFi router to simulate a loss of connectivity.

这篇关于IPhone连接测试:如何强制它失去连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆