Dealing with something as view loaded
I need a function,dealing with something as UIView display on the 开发者_JAVA技巧screen automatically, I think the way to implement it is overwr "- (void)didMoveToSuperview" or "- (void)didMoveToSuperview", am I right? I also want to know more solutions about that.
Really thanks for your help.
Sounds to me like you might want viewWillAppear or viewDidAppear.
Typically, you want to do one-time setup such as setting instance variables in viewDidLoad (technically this can be called again, but only if the view was unloaded and viewDidUnload was called).
For things that might change every time the view is shown, use viewWillAppear (or viewDidAppear).
In any case, make sure to call the super methods:
- (void)viewDidLoad {
[super viewDidLoad];
// do one-time setup here
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// do any setup here that might change each time the view is shown
}
精彩评论