简体   繁体   English

从WiFi切换到3G时出现网络错误

[英]Network error while switching from WiFi to 3G

My iPhone app is web based.It works fine while running in WiFi and in 3G But the problem is when I run the app on WiFi and minimize it,and turn off the WiFi and switch to 3G-it shows no network. 我的iPhone应用程序是基于Web的。它可以在WiFi和3G中运行时正常工作,但是问题是当我在WiFi上运行该应用程序并将其最小化,然后关闭WiFi并切换到3G时,它没有网络。

In user's case-when they use the app under WiFi and goes out it failed to connect with 3G network.I am using apple's Reachability class to check the network connection Anybody please tell any solution 以用户为例-当他们在WiFi下使用该应用程序而无法连接3G网络时,我正在使用Apple的Reachability类来检查网络连接有人请告诉任何解决方案

Do i code something to reconnect if the connection lost or switch from WiFi to 3G ? 如果连接断开或从WiFi切换到3G,我是否可以编写一些代码以重新连接?

You can use connection:didFailWithError: and implement into your method to reconnect your user. 您可以使用connection:didFailWithError:并实现到您的方法中以重新连接用户。

Like this 像这样

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    [self reconnect];
}

- (void)reconnect
{
   //reconnect your user
}

I hope it can help you ! 希望它能对您有所帮助! ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM