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
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.
To clear old contents of webview With UIWebView you would use UIWebViewDelegate 's - webViewDidFinishLoad: .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With