I'm using the below code to try and have a youtube video play inside my app (in a UIWebView). For some reason, my WebView returns as just a black box, and no video plays.
See below:
DashboardViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
NSString *videoURL = @"https://youtu.be/8QrCPihtBSc";
UIWebView *videoView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.howtoView.frame.size.width, self.howtoView.frame.size.height)];
self.howtoView.backgroundColor = [UIColor whiteColor];
self.howtoView.opaque = NO;
self.howtoView.delegate = self;
[self.howtoView addSubview:videoView];
NSString *videoHTML = [NSString stringWithFormat:@"\
<html>\
<head>\
<style type=\"text/css\">\
iframe {position:absolute; top:50%%; margin-top:-130px;}\
body {background-color:#000; margin:0;}\
</style>\
</head>\
<body>\
<iframe width=\"100%%\" height=\"240px\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>\
</body>\
</html>", videoURL];
[videoView loadHTMLString:videoHTML baseURL:nil];