iPhone app startup

2019-07-11 16:54发布

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!

4条回答
聊天终结者
2楼-- · 2019-07-11 17:21

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.)

查看更多
一夜七次
3楼-- · 2019-07-11 17:24

Set UIApplicationExitsOnSuspend to YES int the Info.plist.

查看更多
男人必须洒脱
4楼-- · 2019-07-11 17:34
- (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. */

查看更多
你好瞎i
5楼-- · 2019-07-11 17:40

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.

查看更多
登录 后发表回答