ios - 在 iphone 浏览器上嵌入 Youtube 时应用 css

标签 ios iphone css html youtube

我想在浏览器上播放嵌入 YouTube 时应用 CSS。它在 iPad 上运行良好,但在我的 iPhone(iOS7) 上运行不佳。我认为解决方案不是启动应用程序,而是继续在浏览器中播放。但如何在 iPhone 中做到这一点?

我知道如果禁用 iPhone 的常规设置,我可以在 iPhone 的浏览器中打开 YouTube 链接。但我不想要求每个用户都这样做。

我应该使用视频标签来做到这一点吗?

最佳答案

sample app

 - (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/

相关文章:

ios - Xcode 即席配置

ios - Iphone map 套件 : displaying a image on a map

iphone - iOS 6 模拟器键盘没有响应

javascript - "Responsive"Chart.js图表​​比包含窗口高

iOS 检查连接的外围设备 - Xamarin

ios - 在 Swift 中从相机裁剪图像而无需移动到另一个 ViewController

javascript - 用于在视口(viewport)中检测溢出滚动容器中的图像的交集观察器不起作用

Jquery 更改特定缩略图的 z-index

ios - 是否可以在不使用 iOS 的 json 中使用 alert 属性的情况下发送推送通知?

iphone - uitextview 中的文本编辑器