0
UIWebView *webview=[[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 150, 120)];
NSString *media=@"http://www.youtube.com/watch?v=kG2BYhjQIKQ";
NSString *html = [NSString stringWithFormat:youTubeVideoHTML,media, 150, 120];

[webview loadHTMLString:html baseURL:nil];
[cell.contentView addSubview:webview];

它不工作,它只显示白色视图。

4

2 回答 2

1

要在 webView 上播放 youtube 视频,请尝试以下操作:

NSString *youTubeVideoHTML = @"<html><head>\
                          <body style=\"margin:0\">\
                          <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
                          width=\"%0.0f\" height=\"%0.0f\"></embed>\
                          </body></html>";

    // Populate HTML with the URL and requested frame size
    NSString *html = [NSString stringWithFormat:youTubeVideoHTML, urlString, frame.size.width, frame.size.height];

    // Load the html into the webview
    [self loadHTMLString:html baseURL:nil];
于 2012-06-19T08:55:34.857 回答
1

[webview loadHTMLString:html baseURL:nil]; 用于加载到 UITextview 如果你想使用 UIwebview 手段

[webView loadRequest:[NSURLRequest requestWithURL:url]];
于 2012-06-19T08:42:34.317 回答