Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript中的addEventListener不会在iOS UIWebView上执行_Javascript_Ios_Objective C_Uiwebview - Fatal编程技术网

javascript中的addEventListener不会在iOS UIWebView上执行

javascript中的addEventListener不会在iOS UIWebView上执行,javascript,ios,objective-c,uiwebview,Javascript,Ios,Objective C,Uiwebview,我在object.html函数中有以下代码来获取视频暂停通知: <script type="text/javascript"> var myPlayer = document.getElementById("example_video_1"); myPlayer.addEventListener('pause',function(){window.location.href = "yourapp://buttonClicked";},false); </scri

我在object.html函数中有以下代码来获取视频暂停通知:

<script type="text/javascript">
    var myPlayer = document.getElementById("example_video_1");
    myPlayer.addEventListener('pause',function(){window.location.href = "yourapp://buttonClicked";},false);
</script>
但是我在objective-c中从未收到过这样的通知:当我暂停视频时,没有发生跳转(shouldStartLoadWithRequest函数没有被调用)。我如何解决这个问题?Thx


顺便说一句,我使用的方法是,我完全按照这个链接告诉我的做了。

在UIWebView中播放/暂停视频时没有官方通知。查看这个问题的答案,了解详细的解释和可能的解决方法:我尝试了这个答案,但它不再适用于ios8。
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    NSLog(@"The value of path is:%@",[request.URL path]);

    if ([[request.URL scheme] isEqual:@"yourapp"]) {
        if ([[request.URL path] isEqual:@"buttonClicked"]) {
            NSLog(@"====================");
        }
        return NO; // Tells the webView not to load the URL
    }
    else {
        return YES; // Tells the webView to go ahead and load the URL
    }
}