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

Ind*_*ore 4 iphone ios phonegap-plugins cordova

这是我的代码

    //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");
    }
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

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

Ind*_*ore 6

这是来自文档

iOS Quirks

在暂停处理程序中,任何通过Objective-C的调用都不起作用,也不会发生任何交互式调用,如警报.这意味着您无法调用console.log(及其变体),也无法调用Plugins或PhoneGap API中的任何调用.这些只会在应用程序恢复时处理(在下一个运行循环中处理).