Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - UIWebView not working due to parsing error

Tags:

I want to play a Youtube video in my app. So, I wrote the following code

NSString *embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>";  NSString* html = [NSString stringWithFormat:embedHTML, videoURL, self.view.frame.size.width, self.view.frame.size.height];    [videoView loadHTMLString:html baseURL:nil];  

The videoView is a UIWebView. This was working just fine until later, the view shows nothing. Just a blank white view. And I got this log:

*** WebKit discarding exception: <NSRangeException> *** -[__NSCFString substringToIndex:]: Range or index out of bounds 
like image 341
Abdalrahman Shatou Avatar asked Sep 13 '12 04:09

Abdalrahman Shatou


People also ask

What is UIWebView in iOS?

What is UIWebView? UIWebView is a deprecated iOS user interface control in Apple's UIKit framework. It loads HTML files and web content into an app view, rendering them as they would appear in a browser window. See developer.apple.com/documentation/uikit/uiwebview.

How can I clear the contents of a UIWebView Wkwebview?

To clear old contents of webview With UIWebView you would use UIWebViewDelegate 's - webViewDidFinishLoad: .


1 Answers

Use:

http://www.youtube.com/v/XXXXXXX

instead of:

http://www.youtube.com/watch?v=XXXXXXX

Found here: https://devforums.apple.com/message/705665#705665

like image 156
Richard Poirier Avatar answered Sep 19 '22 19:09

Richard Poirier