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

编程入门 行业动态 更新时间:2024-10-12 16:26:15
本文介绍了暂停事件在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中无法正常工作?

本文发布于:2023-11-27 19:59:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639401.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   事件   工作   iPhone   PhoneGap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!