限制 iOS 应用程序只能使用 wifi?
我正在寻找一种方法来限制我的 iOS 应用程序(甚至其中的一部分)仅使用 wifi。我浏览了可达性示例,但还没有真正找到解决方案。当用户连接到 3g 时,我可以让它显示一条消息,但我不知道如何让它停止加载视图。
我有一个视图,当按下按钮时会加载另一个视图。如果设备连接到 3g,我希望关闭第二个视图。我该怎么做呢?
I am looking for a way to restrict my iOS app (or even a portion of it ) to wifi only. I've looked through the reachability example and haven't really come up with a solution. I can get it to display a message when the user is connected to 3g, but I don't know how to get it to stop loading the view.
I have a view that loads another view when a button is pressed. I want that second view to close if the device is connected to 3g. How can I go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前从未做过您想要做的事情,但我想这只是弄清楚 Reachability API 的问题。
我将从 AppDelegate 类中的一些代码开始:
这是一段非常简单的代码。您在这里可以做的是监听可达性状态的变化,然后设置您的应用程序以做出适当的反应。您不一定必须在 AppDelegate 类中执行此操作。这完全取决于您想要实现的目标。
I've never done what you're trying to do before, but I imagine it's just a matter of figuring out the Reachability API.
I'd start out with some code in your AppDelegate class:
It's a really simple piece of code. What you could do here is listen for changes in reachability status and then set up your app to react appropriately. You don't necessarily have to do this in your AppDelegate class. It all depends on what you want to accomplish.