开发者

catch objective-c loadRequest loading blank page

开发者 https://www.devze.com 2023-01-10 07:37 出处:网络
How would one catch loadRequest returning a 404 page, i am calling the load request like so: [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:qype_url]]];

How would one catch loadRequest returning a 404 page,

i am calling the load request like so:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:qype_url]]];

can't seem to figure o开发者_如何学运维ut how to catch what it returns so i can deal with this situation and load an error page. If the url is incorrect a blank page is returned for example: http://i.qype.co.uk/place/2535934 but how do i catch this in my code? thanks!


You can listen for

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error

part of UIWebViewDelegate


I found a solution for catching pages such as 404's which do not fire the didFailLoadWithError method.

- (SCNetworkReachabilityRef)reachabilityRefForHostName:(NSString *)hostName

http://developer.apple.com/iphone/library/samplecode/Reachability/Introduction/Intro.html

0

精彩评论

暂无评论...
验证码 换一张
取 消