如何防止应用程序/游戏在一段时间后恢复时崩溃

发布于 2024-12-11 17:47:40 字数 183 浏览 0 评论 0原文

我使用 cocos2d 制作的游戏在 iOS5 上从后台恢复一段时间后崩溃了。我想知道处理发送到后台的应用程序的标准/最佳实践是什么。我要在一定时间后终止它吗?我看到有些游戏在很长时间后恢复时会弹出加载屏幕,但当您立即恢复时,它会直接进入游戏。当他们恢复时他们正在加载什么?

任何正确方向的指示将不胜感激。

谢谢 交流电

My game made using cocos2d crashes on iOS5 after resuming from the background when left for a while. I want to know what the standard/best practice is, on handling an app that is sent to the background. Do I terminate it after a certain time? I see some games pull up a loading screen when you resume it after a long time but when you resume it immediately it goes straight to the game. What are they loading when they resume?

Any pointers in the right direction would be much appreciated.

Thanks
AC

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梓梦 2024-12-18 17:47:40

您可以通过添加选择退出后台执行UIApplicationExitsOnSuspend 到您的 Info.plist

除此之外,确保您的应用程序在恢复执行时不会崩溃确实是您的工作。你必须明白你的应用程序基本上进入了暂停状态。这意味着它应该卸载所有不需要的资源,否则系统可能会终止您的应用程序的进程。

在您的应用程序委托中,您应该响应 applicationDidBecomeActive 消息并做出相应响应,以便您的应用能够恢复执行没有任何问题。这可以包括加载任何已卸载的资源并检查系统设置(即区域设置、游戏中心用户等)是否已更改。

您还可以注册一个 didBecomeActive UINotification,以便任何当应用程序应该恢复时,应用程序中的类会收到通知。

You can opt out of background execution by adding UIApplicationExitsOnSuspend to your Info.plist.

Other than that it really is your job to ensure that your app doesn't crash when it resumes execution. You have to understand that your application basically enters a suspended state. That means it should unload all unneeded resources, otherwise the system may terminate your app's process.

In your app delegate you should respond to the applicationDidBecomeActive message and respond accordingly so that your app is able to resume execution without any issues. This can include loading any unloaded assets and checking if system settings (ie. locale, Game Center user, etc.) have changed.

You can also register a didBecomeActive UINotification so that any class in your app gets notified when the app should resume.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文