ios - 如何显示 HTML5 页面

标签 ios html

我使用 Google Web Designer 创建了一个 HTML5 页面。 Here

在模拟器中,自动播放功能无法正常工作。

视频也像下图一样被复制。

enter image description here

我用来展示的代码是:

- (void)viewWillAppear:(BOOL)animated{
NSURL *url = [NSURL URLWithString:@"http://finedine.s3.amazonaws.com/finedine_ads/video_ad.html"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval: 10.0];
[webView loadRequest:requestObj];
self.webView.scalesPageToFit = YES;
}

我该如何解决这个问题?

更新:我用下面的代码显示它:

    if(!adView.isBeingPresented){
        UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
                                                                 bundle: nil];
        adView= (AdViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"AdViewController"];
    }
   if(![adView isBeingPresented])
      [[KGModal sharedInstance] showWithContentViewController:adView];
        //[self.window.rootViewController presentViewController:adView animated:YES completion:nil];

最佳答案

由于限制,嵌入 webview 时自动播放将不起作用,必须在网页上的某种触摸交互时调用 video.play()

User Control of Downloads Over Cellular Networks

In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it. This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. In other words, a user-initiated Play button works, but an onLoad="play()" event does not.


关于视频中出现的双屏,这是youtube 提供的嵌入式视频的3d 版本。我没有使用过 Google Web Designer,但可能有某种设置可以加载另一种视频。

关于ios - 如何显示 HTML5 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21946065/

相关文章:

html - 我如何居中这个中间图像?

javascript - 无法获取div的宽度

ios - 架构 i386 的 undefined symbol : "_OBJC_CLASS_$_Barcode", 引用自:objc-class-ref in

ios - 实现前置视频 iAd

iphone - 阻塞主线程直到 UIWebView 完成加载

html - 如何将一个 div 始终置于另一个 div 之上? (不是叠加!)

ios - App Store 上 iOS 应用程序的桌面网页预览

ios - 导出 Swift 框架以便在 Objective-C 中使用

html - 如何使用 css 将响应式图像拆分为两个 div block ?

javascript - 在页面加载后设置 Ace Editor 光标位置