iPhone 应用程序启动
如何让我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要将 info.plist 文件中的
UIApplicationExitsOnSuspend
键设置为YES
。然后,当按下主页按钮时,应用程序将退出,并在再次打开时重新启动。You need to set the
UIApplicationExitsOnSuspend
key in your info.plist file toYES
. Then the app will quit when the home button is pressed, and launch fresh when it is opened again.这可能只是因为您的应用程序并未真正停止而发生 - 它只是被置于后台。 (如果您在查看跳板时双击主页按钮,它会显示在底部吗?如果是,则它仍在运行。)
您可以通过设置
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.)/*
当应用程序即将从活动状态转变为非活动状态时发送。对于某些类型的临时中断(例如来电或 SMS 消息)或当用户退出应用程序并开始转换到后台状态时,可能会发生这种情况。
使用此方法可以暂停正在进行的任务、禁用计时器并降低 OpenGL ES 帧速率。游戏应该使用此方法来暂停游戏。
*/
/*
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.
*/
将
Info.plist
中的UIApplicationExitsOnSuspend
设置为YES
。Set
UIApplicationExitsOnSuspend
toYES
int theInfo.plist
.