Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 589
amarkon Avatar asked Oct 31 '13 18:10

amarkon


4 Answers

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

like image 188
Hai Hw Avatar answered Oct 29 '22 01:10

Hai Hw


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.

like image 44
user3225101 Avatar answered Oct 29 '22 01:10

user3225101


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];
like image 1
Nikos M. Avatar answered Oct 29 '22 02:10

Nikos M.


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

actually https:// is the keyword.

like image 1
Premal Khetani Avatar answered Oct 29 '22 01:10

Premal Khetani