我面临着我似乎无法理解的问题。
我的这段代码在 Xcode 5 和 iOS 7 中完美运行:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;
UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
NSString* embedHTML = @"\
<html><head><meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; user-scalable=0;\"/>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: black;\
}\
</style>\
</head><body style=\"margin:0;\">\
<embed id=\"yt\" src=\"https://www.youtube.com/v/M7lc1UVf-VE?hd=1\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, width, height];
[webview loadHTMLString:html baseURL:nil];
[self.view addSubview:webview];
}
当我在 iOS 8 的 Xcode 6 中构建相同的代码时,视频会显示在 Web 视图中,但太小了。
谁能解释一下这里发生了什么以及我如何克服这个问题?
我遇到了同样的问题,我使用这个解决方案解决了
https://developers.google.com/youtube/v3/guides/ios_youtube_helper
也在 YTPlayerView.m (〜行:610)中尝试以下更改:
[playerParams setValue:[NSString stringWithFormat: @"%0.00f", self.frame.size.height] forKey:@"height"];
// [playerParams setValue:@"100%" forKey:@"height"];
[playerParams setValue:[NSString stringWithFormat: @"%0.00f", self.frame.size.width] forKey:@"width"];
// [playerParams setValue:@"100%" forKey:@"width"];
希望这有帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)