1
嘿家伙我是iOS新手,所以请耐心等待。iOS - 在缓慢/有损连接上的UIWebView刷新问题
我创建了一个webview为了使一个网络应用程序原生的iOS和应用程序当前在商店。 但是,有些用户在重新加载有损/慢速连接的视图(在警报消息中)时遇到问题。我使用'网络链接调节器'工具对其进行了测试,并在慢速连接时即使尝试刷新页面时也会弹出警告。 下面是我的代码,希望你能帮我解决这个问题。
//Overide the default error message by adding error handling mecanism
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"You must be connected to the internet to use HIPPOmsg. Try again or click the home button to quit"
delegate:self
cancelButtonTitle:@"Try again"
otherButtonTitles:nil];
[alert show];
[alert release];
}
//Implement the 'Try again' button action
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) {
NSURL *url = [NSURL URLWithString:@"https://app.hippomsg.com/home.php"];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[webView loadRequest:req];
}
}
感谢您的帮助 – fab327