Sunday, December 15, 2013

Why does my program before exiting into viewWillDisappear? ?

 
# Import "Untitled19ViewController.h"

@ Implementation Untitled19ViewController



/ *
/ / The designated initializer. Override to perform setup that is required before the view is loaded.
- (Id) initWithNibName: (NSString *) nibNameOrNil bundle: (NSBundle *) nibBundleOrNil {
self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil];
if (self) {
/ / Custom initialization
}
return self;
}
* /

/ *
/ / Implement loadView to create a view hierarchy programmatically, without using a nib.
- (Void) loadView {
}
* /



/ / Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (Void) viewDidLoad {
[Super viewDidLoad];
}

- (Void) viewWillAppear: (BOOL) animated
{
float f = [[NSUserDefaults standardUserDefaults] floatForKey: @ "slidervalue"];
slider.value = f;
NSLog (@ "1");
}

- (Void) viewWillDisappear: (BOOL) animated
{
NSLog (@ "2");

float f = slider.value;
[[NSUserDefaults standardUserDefaults] setFloat: f forKey: @ "slidervalue"];

}


/ *
/ / Override to allow orientations other than the default portrait orientation.
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
/ / Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
* /

- (Void) didReceiveMemoryWarning {
/ / Releases the view if it doesn't have a superview.
[Super didReceiveMemoryWarning];

/ / Release any cached data, images, etc that aren't in use.
}

- (Void) viewDidUnload {
/ / Release any retained subviews of the main view.
/ / E.g. self.myOutlet = nil;
}


- (Void) dealloc {
[Super dealloc];
}

@ End



Reply:
Normal is appdelegate the dealloc is not called.
If you want to do something, then quit before, do things in the applicationwillterminate
Reply:
I appeared in the same issue and the landlord does not call when you press the Home key to exit viewWillDisappear, the landlord to solve this problem? ? Ask. . .
Reply:
Just one view controller's view, is not going to call - (void) viewWillDisappear: (BOOL) animated
- (Void) viewDidDisappear: (BOOL) animated these two, because the view controller's view has not changed, even after the run to open the application or that view appears, exit to the background, too.
Reply:
Do not enter the program exits this function!
This call is
 - (void) applicationWillTerminate: (UIApplication *) application 
{
NSLog (@ "% @", NSStringFromSelector (_cmd));
}

Reply:
Home key when not quit, just into the background only, so do not enter the proxy method is normal. applicationDidEnterBackground agent into the background of this method will be triggered
Reply:
ios4.0 or more, generally do not call applicationWillTerminate
in iOS 4.0 and later, this method is called instead of the applicationWillTerminate:. method when the user quits an application that supports background execution You should use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. You should also disable updates to your application's user interface and avoid using some types of shared system resources (such as the user's contacts database). It is also imperative that you avoid using OpenGL ES in the background.
Reply:
The reply was deleted at the moderator 2011-12-13 11:01:57

Reply:
Press the home key, the call is the
- (Void) applicationWillTerminate: (UIApplication *) application
{


}


Reply:
The problem I also find it strange,
Perhaps apple issues now.
Reply:
Apple's implementation mechanism is so right
Reply:
I tried it and found that is so:
Find other posts on the Internet, probably said so.
http://stackoverflow.com/questions/4289617/why -isnt-viewwilldisappear-or-viewdidappear-being-called

http://stackoverflow.com / questions/6583834/iphone-why-not-deallocate-in-viewwilldisappear-and-allocate-in-viewwillappear

If your viewController is first added to the window;
Then exit the application, they will not enter the viewController of viewWillDisappear, it does not go in the same dealloc.
I'm in the application delegate dealloc hit a breakpoint, like do not go.

However, if it is on the basis of this viewController, then add a new viewController, then
of new viewControllerviewWillDisappear is normally called.

Summary: probably because efficiency reasons. First into the viewController do this deal, avoid construction again.



No comments:

Post a Comment