【问题标题】:Apply css in embed Youtube on iphone browser在 iphone 浏览器上应用 css 嵌入 Youtube
【发布时间】:2014-01-23 14:11:09
【问题描述】:

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

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

我应该使用视频标签吗?

【问题讨论】:

  • 用于 iphone 的网页浏览
  • 你能在浏览器中嵌入 webview 代码吗?

标签: ios iphone css html youtube


【解决方案1】:

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

【讨论】:

  • 但是这样也启动了一个看youtube的专用播放器?你的意思是我应该编辑youTubeVideoHTML并添加css?
猜你喜欢
  • 2013-06-28
  • 1970-01-01
  • 1970-01-01
  • 2018-02-12
  • 1970-01-01
  • 2015-02-19
  • 2015-08-19
  • 1970-01-01
  • 2012-02-15
相关资源
最近更新 更多