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:
Does anyone know why the UIWebView is returning the error?
You should check the URL path
It should be @"http://google.com" instead of @"google.com"
Use https://www.google.com Or http://www.google.com
actually https:// is the keyword.
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:
The reason the frame load interrupted error is being displayed is that
www.youtube.com
is performing a redirect tom.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.Its quite clear.. you're not setting the "frame" of WebView. Use this :
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: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.