嵌入未在UICollectionView上显示的YouTube视频

时间:2013-09-29 20:01:06

标签: embed ios7 uicollectionviewcell

所以我在使用UICollectionView时遇到了另一个问题。

这次我试图在UICollectionViewCell上显示嵌入视频(YouTube)。

Embed方法不起作用,它给我空白单元格。

如果我直接使用路径,可以使用,但它会在Youtube上显示整个页面而不是仅显示视频。

知道它会是什么吗?

以下是代码:

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    L4VideoCell *videocell = [collectionView dequeueReusableCellWithReuseIdentifier:@"videoCell" forIndexPath:indexPath];
    videocell.backgroundColor = [UIColor whiteColor];

    NSString *webpath = @"<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/rmx55fxRK5A?rel=0\" frameborder=\"0\" allowfullscreen></iframe>";
    [videocell.webAudioView loadHTMLString:webpath baseURL:nil];


    return videocell;

}

1 个答案:

答案 0 :(得分:0)

好的,发现了这个问题。

我不确定这个原因是否有效,但它对我有用。

之前,我正在传递baseURL:nil。我添加了自己的基本URL,但它确实有效。

[webview loadHTMLString:"Embed URL from YouTube" baseURL:[NSURL URLWithString:@"http://www.myurl.com"]];

希望它有所帮助。

相关问题