这是我的代码
//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中无法正常工作?
发布评论