我有一个iPhone应用程序,我想要一个视图推送到UIWebView可能会显示特定搜索词的YouTube视频的搜索结果。然后我希望用户能够选择视频并在应用程序中播放。
我查看了youtube教程,但似乎无法掌握如何做到这一点。
答案 0 :(得分:2)
http://iosdevelopertips.com/video/display-youtube-videos-without-exiting-your-application.html
答案 1 :(得分:0)
以下是我在视图控制器中使用UIWebView:
的方法- (void)embedYouTubeWithURLString:(NSString *)urlStr {
CGFloat w = webView.frame.size.width;
CGFloat h = webView.frame.size.height;
NSString *embed = [NSString stringWithFormat:@"<html><head><meta name=\"viewport\""\
" content=\"initial-scale=1.0, user-scalable=no, width=%0.0f\"/></head><body "\
"style=\"background-color:transparent;margin-top:0px;margin-left:0px\"><div><object "\
"width=\"%0.0f\" height=\"%0.0f\"><param name=\"movie\" value=\"%@\" /><param name=\"wmode"\
"\"value=\"transparent\" /><param name=\"allowFullScreen\" value=\"true\" /><param"\
" name=\"quality\" value=\"high\" /><embed src=\"%@\" type=\"application/x-shockwave-flash"\
"\" allowfullscreen=\"true\" wmode=\"transparent\" width=\"%0.0f\" height=\"%0.0f\" />"\
"</object></div></body></html>", w, w, h, urlStr, urlStr, w, h];
[webView loadHTMLString:embed baseURL:nil];
}