暂停事件在PhoneGap iPhone中无法正常工作? [英] pause event is not working properly in PhoneGap iPhone?

查看:113
本文介绍了暂停事件在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");
    }

当我按主页按钮时,控制台没有日志,单击应用程序(使其在前台),然后我的日志是

When i press the home button there is no log in the console however when I click the app (make it in foreground) then my log is

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

我不知道为什么暂停函数在前台调用。

有什么我'

I don't know why pause function is called when it comes in foreground.
Is there anything that I'm doing wrong?

推荐答案

iOS Quirks


在暂停处理程序中,通过Objective-C的任何调用都不会工作,也不会有任何交互式调用(如警报)。这意味着您不能调用console.log(及其变体),或者来自插件或PhoneGap API的任何调用。只有在应用程序恢复(在下一个运行循环上处理)时,才会处理这些操作。

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).

这篇关于暂停事件在PhoneGap iPhone中无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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