How to resolve “Frame Load Interrupted” error in UIWebView?

冷暖自知 提交于 2019-12-01 15:47:51

You should check the URL path
It should be @"http://google.com" instead of @"google.com"

user3225101

I have the same issue, in my case it turns out to be the MIMEType not being set properly.

I tested by manually creating a NSURLConnection with the request from URL, and then implemented:

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response

to observe the response callback from the connection. The response's MIMEType turned out to be "pdf/pdf" instead of "application/pdf," and soon as I fix that issue the webview loaded the url just fine.

Hope this helps.

The url you use probably does not recognize the user agent. That was an issue that occured in older iOS versions too, but seems to have returned in iOS 7. Try adding this to your appdelegate didFinishLaunchingWithOptions:

NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];

Use https://www.google.com Or http://www.google.com

actually https:// is the keyword.

I faced same issue on iOS 10.2.1 UIWebView.

when request pdf file with path URL

the pdf file has MIMEType "application/x-pdf".

so I changed to "application/pdf" and can read this

The reason the frame load interrupted error is being displayed is that www.youtube.com is performing a redirect to m.youtube.com, which UIWebView doesn't like. To wildly speculate, I would cite possible security implications? I was able to resolve this issue by linking directly to the mobile site, removing the need for youtube to redirect.

I had a similar problem to those who reported that adding or correcting the mime type fixed the issue. In my case, I was attempting to open a local file without an file extension (e.g. "my-dir/my-file") and that resulted in the dreaded "Frame Load Interrupted" error (along with "Unbalanced calls to begin/end appearance transitions for UIViewController"). Adding the file extension (e.g. "my-dir/my-file.pdf") corrected the problem for me.

Its quite clear.. you're not setting the "frame" of WebView. Use this :

_webView = [[UIWebView alloc] initWithFrame:self.view.frame]; //give a proper Rect value
_webView.delegate = self;
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:_url];
[_webView loadRequest:request];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!