I use the following embed code to embed my YouTube videos in iOS
- (NSString*)embedYouTube:(NSString*)youtube_id frame:(CGRect)frame { NSString* embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <iframe src=\"http://www.youtube.com/embed/%@?rel=0\" frameborder=\"0\" allowfullscreen width=\"%0.0f\" height=\"%0.0f\"></iframe>\ </body></html>"; NSString *html = [NSString stringWithFormat:embedHTML, youtube_id, frame.size.width, frame.size.height]; return html; } //code to embed video NSString *contentHTML; if (currentAnswer.youtube_id != nil) { contentHTML = [self embedYouTube:currentAnswer.youtube_id frame:CGRectMake(CELL_TEXT_LEFT_MARGIN + CELL_AVATAR_WIDTH + CELL_SPACING, currentYAxisValue, CELL_YOUTUBEVIEW_WIDTH, CELL_YOUTUBEVIEW_HEIGHT)]; } [webView loadHTMLString: contentHTML baseURL:nil];
When I play a video, it only plays in potrait mode, not landscape mode. Is this a limitation due to iframes, is there any way to do this?
source share