I using a UIWebView in a game to display a customer support form. I noticed i have problem to close the webview if the server return a 503 error (http status code sent from a load balancer)
Is there a way to easily get this http status ? can I do some setup in order to get the didFailWithError called when the http status code is not 200 ?
loading code
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];
NSURL *nsURL = [NSURL URLWithString:url];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:nsURL];
webView.opaque = YES;
webView.userInteractionEnabled = YES;
[webView loadRequest:request];
webView.delegate = self;
closableWebViewController = [[UIViewController alloc] init];
[closableWebViewController.view setFrame:self.view.frame];
[closableWebViewController.view addSubview:webView];
[self presentViewController:closableWebViewController animated:YES completion:nil];
this delegate method is not called
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"webview error %@",error);
if (closableWebViewController)
{
NSLog(@"closing webview");
[closableWebViewController dismissViewControllerAnimated:TRUE completion:^{
closableWebViewController = nil;
NSLog(@"webView closed");
}];
}
}