如何在属于 UITableViewCell 一部分的 UIWebView 中使用 YouTube 视频的嵌入标签

发布于 2024-10-06 16:49:55 字数 1044 浏览 0 评论 0原文

我可以成功使用嵌入标签将 YouTube 视频嵌入到不属于表格单元格的 UIWebView 中。

我可以在作为表格单元格一部分的 UIWebView 中成功设置 html。

但是,使用嵌入标签链接到 YouTube 视频在作为表格单元格一部分的 UIWebView 中设置 html 对我来说不起作用。

我的自定义 UITableViewCell 类中的代码如下所示:


   NSString *embedHTML = @"\
    <html><body>\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
 width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";

    CGRect frame = self.webView.bounds;
 NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
    [self.webView loadHTMLString:html baseURL:nil];

如果我替换“”像“

测试

”这样简单的东西,它就会像我期望的那样出现。

如果我在具有 webView 的非表视图控制器中使用带有嵌入标记的代码片段,它就可以正常工作。

我是否做错了什么,或者 UITableViewController 和关联的类只是不允许我这样做?

谢谢, Doug

--------- 2010 年 12 月 8 日更新

我可以成功使用“”或“<视频...>” UIWebView 中的标签是 UITableViewCell 的一部分除了 YouTube 视频

所以,问题标题仍然准确,但我不再怀疑 YouTube 链接有很大不同。

I can successfully use the embed tag to embed a youtube video in a UIWebView that is NOT part of a table cell.

I can successfully set the html in a UIWebView that IS part of a table cell.

But, setting the html in a UIWebView that IS part of a table cell using the embed tag to link to a youtube video does not work for me.

The code in my custom UITableViewCell class looks like this:


   NSString *embedHTML = @"\
    <html><body>\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
 width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";

    CGRect frame = self.webView.bounds;
 NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
    [self.webView loadHTMLString:html baseURL:nil];

If I replace the "<embed ...>" with something simple like "<p>testing</p>", it shows up just like I expect it to.

If I use the code snippet with the embed tag in a non-table view controller that has a webView, it works just fine.

Am I doing something wrong, or are the UITableViewController and associated classes just not going to let me do this?

Thanks,
Doug

--------- Update on 08-Dec-2010

I can successfully use the "<embed ...>" or "<video ...>" tags in a UIWebView that is part of a UITableViewCell EXCEPT for YouTube videos.

So, the question title is still accurate, but I no longer have any doubt that there is something much different about the YouTube link.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我是男神闪亮亮 2024-10-13 16:49:55

我重新开始一个新项目并让它发挥作用。

由于第一个项目只是一个原型,我认为我做了一些破坏行为的事情——现在不确定是什么,事情看起来大致相同。

I started over with a fresh project and got it working.

Since the first project was just a prototype, I assume I did something that broke the behavior -- not sure what right now, things look roughly the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文