iPhone - 快速应用程序切换和 iOS 4

发布于 2024-10-03 07:44:46 字数 672 浏览 2 评论 0原文

我正在尝试在我的 iPhone 应用程序中获得以下功能:

  • 当后台运行时,保持运行(不必执行任何后台工作)
  • 当恢复时,应用程序会从上次中断的位置继续

我主要想要打开相同的屏幕我的应用程序仍然运行,因为 UITabBarController 中有几个 UINavigationController。

我已完成以下所有操作:

  • 确保我使用 4.1 SDK 进行编译
  • 将UIApplicationExitsOnSuspend 设置为 false
  • 在我的 AppDelegate 中处理 DidEnterBackground 和 WillEnterForeground
  • 在 DidEnterBackground 中调用 BeginBackgroundTask,以尝试保持我的应用程序打开

我正在使用 MonoTouch,但它可能跑题了。我当然可以在 Obj-C 中得到答案。

我已经使用后台程序在越狱手机上测试了我的应用程序,并且我看到“后台应用程序”徽章在按下主页按钮后立即消失。我也尝试在 Info.plist 中设置 UIBackgroundModes,但无济于事。

我有什么遗漏的吗?

或者这是我必须自己实现才能恢复我的应用程序之前的状态?我在任何地方读过的演讲都说它应该自动工作。

I'm trying to get the following functionality in my iPhone app:

  • When backgrounded, stays running (doesn't have to do any background work)
  • When resumed, app picks up where it was left off

I'm mainly wanting the same screen on my app still up, as there are several UINavigationControllers within a UITabBarController.

I have done all of the following:

  • Made sure I'm compiling with 4.1 SDK
  • Set UIApplicationExitsOnSuspend to false
  • Handle DidEnterBackground and WillEnterForeground in my AppDelegate
  • Call BeginBackgroundTask in DidEnterBackground, to attempt to keep my app open

I'm using MonoTouch, but that it probably beside the point. I can take answers in Obj-C, for sure.

I've tested my app on a jailbroken phone with Backgrounder, and I see the "app in background" badge disappear immediately after pushing the home button. I also tried setting UIBackgroundModes in my Info.plist, but to no avail.

Is there anything I'm missing?

Or is this something I would have to implement on my own to resume the previous state of my app? Everywhere I've read talks like it should just work automatically.

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

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

发布评论

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

评论(4

初懵 2024-10-10 07:44:47

我终于在 MonoTouch 的 irc 上联系到了某人。

在 MonoDevelop 中,有一个选项可以制作双 iPad/iPhone 项目,我使用了它。这导致我的应用程序在部署到设备时表现得就像使用 3.2 SDK 运行一样。

我认为我的解决方案是安装刚刚发布的 iOS 4.2 SDK,因为它在 iPad 上宣传了新的多任务功能。

I finally got in touch with someone on MonoTouch's irc.

In MonoDevelop there is an option to make a dual iPad/iPhone project, which I used. This is causing my app to behave as if it's running with the 3.2 SDK when deployed to the device.

I think my solution is to install the iOS 4.2 SDK that just came out, since this ads the new multi-tasking feature on iPad.

烛影斜 2024-10-10 07:44:47

您不仅需要支持进入后台,还需要支持应用程序已终止的情况。在应用程序的初始化代码中,您应该恢复它所处的状态。例如,当您推送视图控制器时,使用 NSUserDefaults 来存储当前显示屏幕的值,然后当您开始读取该值并显示相关屏幕。

Not only do you need to support going into the background, you also need to support cases where your app has been terminated. In your app’s initialization code, you should resume the state that it was in. For instance, when you push a view controller, use NSUserDefaults to store a value for the currently-displayed screen, and then when you start read that value and display the associated screen.

这个俗人 2024-10-10 07:44:46

如果您不想在后台工作,请不要调用 beginBackgroundTask。该调用适用于您想要在后台执行某种工作的情况。如果您没有足够快地完成该工作,iOS 将终止您的应用程序。

If you don't want to be doing work in background, don't call beginBackgroundTask. That call is for situations where you want to do some kind of work in the background. And if you don't finish that work fast enough, iOS will terminate your app.

深居我梦 2024-10-10 07:44:46

当我升级到 iOS 4.x 时,我的 MT 应用程序开始表现出这种行为,而我无需执行任何操作。 iOS 应该会帮你处理好。

When I upgraded to iOS 4.x, my MT application started exhibiting this behavior without me having to do anything. iOS should take care of it for you.

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