将 youtube 视频嵌入 UIView/UIWebView [英] Embeding youtube video into a UIView/UIWebView

查看:35
本文介绍了将 youtube 视频嵌入 UIView/UIWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 YouTube 视频嵌入到 UIView 中,但我不明白为什么视频左上角有这个白色边框.我还设置了 frameborder = 0.不应该有任何白色边框.

i am trying to embed YouTube video into a UIView, but i can't figure out why there is this white border on the top left of the video. I also set frameborder = 0. There shouldn't be any white borders.

这是嵌入 YouTube 视频的代码:我对 UIWebview 和 UIView 都试过了...结果还是一样...

Here is the code for the embed youtube video: I tried it for both UIWebview and UIView... Still the same result...

NSString *embedHTML = @"<span style=\"background-color: #fdeee0;\"><iframe width=\"256\" title=\"YouTube video player\" src=\"http://www.youtube.com/embed/KzN6XWDEmXI?HD=1;rel=0;showinfo=0;controls=1\" height=\"200\" frameborder=\"0\"></iframe>";


    [testWeb loadHTMLString:embedHTML baseURL:nil];
    testWeb.scrollView.scrollEnabled = NO;
    testWeb.scrollView.bounces = NO;
testWeb.contentMode = UIViewContentModeScaleAspectFill;

[test setImage:image];
//[self.view addSubview:test];
self.testView.backgroundColor = [UIColor orangeColor];
[self.testView addSubview:test];
[self.testView addSubview:testWeb];

截图如下:

推荐答案

testWeb.scalePageToFit = YES;

testWeb.scalePageToFit = YES;

http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIWebView/scalesPageToFit

这篇关于将 youtube 视频嵌入 UIView/UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆