Skip to content

Instantly share code, notes, and snippets.

@mretzak
Created October 31, 2012 17:22
Show Gist options
  • Save mretzak/3988459 to your computer and use it in GitHub Desktop.
Save mretzak/3988459 to your computer and use it in GitHub Desktop.
YouTube embed in UIWebview
NSString *embedHTML = @"\
<html><head>\
<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 620\"/></head>\
<script>document.ontouchmove = function(event) {event.preventDefault();}</script>\
<body style=\"background:#000;margin:0px;\">\
<div><iframe width=\"620\" height=\"348\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\" allowfullscreen></iframe>\
</div></body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, url];
UIWebView* webView = [[[UIWebView alloc] init] autorelease];
[webView loadHTMLString:html baseURL:nil ];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment