iPhone 应用程序启动

发布于 2024-10-30 17:37:58 字数 98 浏览 5 评论 0原文

如何让我的 iPhone 应用程序每次都在同一位置启动,即我的“主”屏幕?我不希望用户返回到上次玩游戏的位置 - 就在游戏过程中 - 但这就是正在发生的事情。 预先感谢您的任何提示!

How do I make my iPhone app start at the same place each time, i.e. my 'home' screen? I do NOT want the user to return to where they were last time they played - right in the middle of gameplay - but that's what's happening.
Thanks in advance for any tips!

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

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

发布评论

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

评论(4

失而复得 2024-11-06 17:37:58

您需要将 info.plist 文件中的 UIApplicationExitsOnSuspend 键设置为 YES。然后,当按下主页按钮时,应用程序将退出,并在再次打开时重新启动。

You need to set the UIApplicationExitsOnSuspend key in your info.plist file to YES. Then the app will quit when the home button is pressed, and launch fresh when it is opened again.

喜爱纠缠 2024-11-06 17:37:58

这可能只是因为您的应用程序并未真正停止而发生 - 它只是被置于后台。 (如果您在查看跳板时双击主页按钮,它会显示在底部吗?如果是,则它仍在运行。)

您可以通过设置 UIApplicationExitsOnSuspend 键(在 Xcode 中称为“应用程序不在后台运行”)。请参阅 Apple 的信息属性列表键参考 文档以获取更多信息。

或者,您可以简单地捕获 applicationDidEnterBackground: UIApplicationDelegate 方法在您的应用程序中添加委托并以编程方式处理这种情况。 (即:执行您需要执行的操作将应用程序重置回“主”屏幕等)

This is presumably only happening because your app isn't really being stopped - it's simply being backgrounded. (If you double click the home button whilst viewing springboard does it show up at the bottom? If so, it's still running.)

You can disable this behaviour (so your app quits when the user hits the home button) by setting the UIApplicationExitsOnSuspend key (known as "Application does not run in background" within Xcode) in your info.plist file. See Apple's Information Property List Key Reference docs for more information.

Alternatively, you could simply capture the applicationDidEnterBackground: UIApplicationDelegate method in your app's add delegate and handle the situation from there programatically. (i.e.: Do whatever you need to do to reset your app back to the 'home' screen, etc.)

深海夜未眠 2024-11-06 17:37:58
- (void)applicationWillResignActive:(UIApplication *)application {

[self.navigationController popToRootViewControllerAnimated:YES];   

}

/*
当应用程序即将从活动状态转变为非活动状态时发送。对于某些类型的临时中断(例如来电或 SMS 消息)或当用户退出应用程序并开始转换到后台状态时,可能会发生这种情况。
使用此方法可以暂停正在进行的任务、禁用计时器并降低 OpenGL ES 帧速率。游戏应该使用此方法来暂停游戏。
*/

- (void)applicationWillResignActive:(UIApplication *)application {

[self.navigationController popToRootViewControllerAnimated:YES];   

}

/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/

硪扪都還晓 2024-11-06 17:37:58

Info.plist 中的 UIApplicationExitsOnSuspend 设置为 YES

Set UIApplicationExitsOnSuspend to YES int the Info.plist.

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