微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – 暂停事件在PhoneGap iPhone中无法正常工作?

这是我的代码

//This is an event that fires when a PhoneGap application is put into the background.
    document.addEventListener("pause",onPause,false);

    //This is an event that fires when a PhoneGap application is retrieved from the background.
    document.addEventListener("resume",onResume,false);

    // Handle the pause event
    function onPause(){
    console.log("pause : app is put into background");
    }


    // Handle the resume event
    function onResume() {
    console.log("resume : app is put into foreground");
    }

当我按下主页按钮时,控制台中没有日志,但是当我单击应用程序(将其置于前台)时,我的日志就是

2011-11-22 12:11:37.206 Event[644:207] [INFO] pause : app is put into background
2011-11-22 12:11:37.206 Event[644:207] [INFO] resume : app is put into foreground

我不知道为什么暂停函数在前景中被调用.
有什么我做错了吗?

解决方法

这是来自文档

iOS Quirks

In the pause handler,any calls that go through Objective-C will not work,nor will any calls that are interactive,like alerts. This means that you cannot call console.log (and its variants),or any calls from Plugins or the PhoneGap API. These will only be processed when the app resumes (processed on the next run-loop).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐