iOS UiWebView /页面可见性Api:“pageshow”事件没有解雇 [英] iOS UiWebView / Page Visibility Api: "pageshow" event not firing

查看:570
本文介绍了iOS UiWebView /页面可见性Api:“pageshow”事件没有解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Page Visibility Api来检测何时在iOS中显示Web内容。我有简单的JS:

I am trying to use the Page Visibility Api to detect when web content is being shown in iOS. I have simple JS:


    window.addEventListener("pageshow", function(){
        alert("page shown");
    }, false);


制作标签时,警报会在移动版Safari中按预期触发激活,或者最小化safari然后重新显示。

The alert fires as expected in mobile safari when the tab is made active, or when safari is minimized and then re-shown.

但是如果我在UiWebView中托管Web内容,则事件不会触发。还有其他人遇到过这个问题吗?如果是这样的任何解决方法?

However if I host the web content in a UiWebView, the event is not firing. Has anyone else encountered this issue? If so any work around for this?

谢谢......

推荐答案

UIWebView不支持该事件,但你可以考虑从本机触发你自己的事件

The UIWebView dose not support that event however you could look into triggering the event your self from the app natively

这是你如何从Objective-C $调用JavaScript函数b $ b 目标C将数据发送到phonegap并调用javascript功能

This how you call a JavaScript function from Objective-C Objective C send data to phonegap and call javascript function

然后您只需使用上面的代码在处理启动或重启暂停的应用程序时通知webview

Then you just use the code above to notify the webview when your handling the application being started or restarted from suspension

目标C:如何检查应用程序当前是否处于活动状态(即用户是否正在使用它)?应该有帮助

这篇关于iOS UiWebView /页面可见性Api:“pageshow”事件没有解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆