How do I make sure the application quits properly when I hit the home button? When I hit the home button and open the app again, it starts off from where I left it and it has all the values (I'm making a calculator applicatio开发者_JAVA技巧n). how do I make sure it starts from the beginning and not from where I left it. my app uses pickers and textfields. I added the following code and it's not helping!
- (void)viewDidUnload
{ self.stage_picker = nil;
self.grade_picker = nil;
self.Pos_lymppicker = nil;
self.Ex_lymphpicker = nil;
self.text1 = nil;
self.text2 = nil;
self.text3 = nil;
self.text4 = nil;
[super viewDidUnload];
}
Just add the boolean key UIApplicationExitsOnSuspend or Application does not run in background to your info.plist and set the value to yes
- (void)applicationWillTerminate:(UIApplication *)application
try this one
You can clear the previous values while you start your app or when you close your app.
It is up to you. You can choose either of them.
So better to clear out all data on applicationDidFinishLaunching
method or applicationWillTerminate
method.
Now when you tap home button app goes in background, So if you want it to start freshly even when it is being started after being in background then you can clear out all data in applicationDidnterBackground
method of application delegate.
Hope this helps you
精彩评论