Understanding applicationSignificantTimeChange:(了解 applicationSignificantTimeChange:)
问题描述
我发现有时我的应用程序(Cocos2d 游戏)在经过重大时间更改后会以错误"的方式运行.例如:
I find that sometimes my application (Cocos2d game) beheaves in a "buggy" way after a significant time change. For example:
- 案例1:当应用进入后台,几分钟后重启,我可以看到加载图片,然后应用/游戏恢复.
- 案例 2: 当应用程序进入后台并在很长一段时间后更改应用程序有时会重新启动,有时不会.我仍然不清楚为什么.
- case 1: when the application enters the background and, after several minutes, I restart it, I can see the loading image and then the application/game resumes.
- case 2: when the application enters the background and after a significant time change the application sometimes restarts, sometimes not. It is still unclear to me why.
查看我发现的 AppDelegate 方法:
Looking at the AppDelegate methods I found:
// next delta time will be zero
-(void) applicationSignificantTimeChange:(UIApplication *)application
{
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
}
我想知道,因为这会影响导演,而导演会影响动画,所以此调用与案例 1 和案例 2 之间是否存在联系?
推荐答案
这与cocos2D或applicationSignificantTimeChange:
特别是对于 applicationSignificantTimeChange:
当日期改变时调用此方法,或者如果设备的时间因任何原因在后台发生更改(例如更改时区).
[来源]
This method is called when the day changes, or if the device's time has been changed in the background for whatever reason (such as changes to time zone).
[Source]
我假设您提到的重大时间变化"只是您离开游戏一段时间(即超过几分钟).在这种情况下,您很可能会观察到 当设备内存不足时操作系统多任务处理程序会终止后台进程,从而导致您的应用程序按照您在案例 2 中的描述重新启动.
I am assuming the "significant time change" you mention is just when you leave the game for a while (i.e. longer than a few minutes). In this case, it's most likely that you are observing the fact that the OS multitasking handler kills off background processes when the device is running low on memory, causing your app to restart as you describe in case 2.
在应用程序没有重新启动的情况下,这只是操作系统没有杀死你的进程的情况.
In the cases where the app hasn't restarted, it's just the case that the OS hasn't killed your process.
这篇关于了解 applicationSignificantTimeChange:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:了解 applicationSignificantTimeChange:


- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01