Dev138
Dev138

Reputation: 336

Youtube iframe not showing in UIWebView

I have an iframe within the html string,

<iframe class='iframeClass' src="https://www.youtube.com/{some_ID}" frameborder=0 width=564 height=347 marginwidth=0 marginheight=0 hspace=0 vspace=0 scrolling=no frameborder=0></iframe>

this works in a browser but not in my UIWebView(in the webview it is just blank where the iframe should be).

Any ideas?

Thanks.

Upvotes: 0

Views: 858

Answers (1)

BCBlanka
BCBlanka

Reputation: 485

I'm afraid your video URL is not valid. Write the following code into your viewDidLoad:

NSString *embedHTML = @"<iframe class='iframeClass' src=\"https://www.youtube.com/embed/rOPI5LDo7mg\" frameborder=0 width=564 height=347 marginwidth=0 marginheight=0 hspace=0 vspace=0 scrolling=no frameborder=0></iframe>";
[self.webview loadHTMLString:embedHTML baseURL:nil];

Upvotes: 2

Related Questions