Do you call [super viewDidDisappear:animated] in iOS?
In the template Apple gives you, I see that they have:
/*
- (void)viewWillAppear:(BOOL)animated {
[super viewWill开发者_运维百科Appear:animated];
}
*/
I understand that you want your super class to do any loading of the view before your own view. For viewDidDisappear, do you do the same thing for the same reason?
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
Yes always call the super class method first to have it complete so then you can override any behaviour subsequently in your inherited classes method.
The only exception to this is the dealloc
method where you should call [super dealloc]
last to make sure you've cleared up your own class properly before any references might get lost and cause a memory leak.
I would say that things should always be taken apart in the opposite order they are built up. You call [super viewWillAppear:animated]
at the beginning of viewWillAppear
so the super class has a chance to set up the default actions, then you get your opportunity to modify.
For the call to [super viewDidDisappear:animated]
you should do your disappearing code before calling the super
one at the end of your viewDidDisappear
. That way if you have any references to the default view contents they are not released before you are done with them. If you don't use anything in the super class then it is probably irrelevant.
精彩评论