我想在浏览器上播放嵌入 YouTube 时应用 CSS。它在 iPad 上运行良好,但在我的 iPhone(iOS7) 上运行不佳。我认为解决方案不是启动应用程序,而是继续在浏览器中播放。但如何在 iPhone 中做到这一点?
我知道如果禁用 iPhone 的常规设置,我可以在 iPhone 的浏览器中打开 YouTube 链接。但我不想要求每个用户都这样做。
我应该使用视频标签来做到这一点吗?
最佳答案
- (UIWebView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame;
{
if (self = [super init])
{
// Create webview with requested frame size
self = [[UIWebView alloc] initWithFrame:frame];
// HTML to embed YouTube video
NSString *youTubeVideoHTML = @"<html><head>\
<body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
// Populate HTML with the URL and requested frame size
NSString *html = [NSString stringWithFormat:youTubeVideoHTML, urlString, frame.size.width, frame.size.height];
// Load the html into the webview
[self loadHTMLString:html baseURL:nil];
}
return self;
}
关于ios - 在 iphone 浏览器上嵌入 Youtube 时应用 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20945463/