How to resolve "Frame Load Interrupted" error in UIWebView?

36,729

Solution 1

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

Solution 2

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.

Solution 3

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

actually https:// is the keyword.

Solution 4

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];

Solution 5

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

Share:
36,729
amarkon
Author by

amarkon

SRE @ HubSpot

Updated on December 15, 2020

Comments

  • amarkon
    amarkon over 3 years

    In an app I'm contracted to build, I'm pulling a list of YouTube videos and allowing them to be displayed in the app. However, when a user taps a cell in the YouTube view's navigation controller and the modal view with a UIWebView appears, the UIWebView returns the error "Frame load interrupted."

    I've run it through the debugger dozens of times, and everything seems to go well until I initialize the NSURLRequest. When the modal view is displayed, here is the code that runs in the ViewController's -viewDidLoad method:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        _webView = [[UIWebView alloc] init];
        _webView.delegate = self;
        NSURLRequest *request = [[NSURLRequest alloc] initWithURL:_url];
        [_webView loadRequest:request];
    }
    

    However, when I pull up the debugger on the line [_webView loadRequest:request];, I see the following:

    enter image description here

    Does anyone know why the UIWebView is returning the error?