开发者

How can I use embed tag for YouTube video in a a UIWebView that is part of a UITableViewCell

开发者 https://www.devze.com 2023-01-29 23:19 出处:网络
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 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 th开发者_StackOverflow社区e 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消