Embeding youtube video into a UIView/UIWebView

旧巷老猫 提交于 2019-12-11 08:36:20

问题


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.

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];

Here is a screenshot:


回答1:


testWeb.scalePageToFit = YES;

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



来源:https://stackoverflow.com/questions/14700759/embeding-youtube-video-into-a-uiview-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!