reloading different view controller when changing settings in current
Here's the situation.
A dictionary app. Lets imagine we've searched for some article and opened it in view controller in Tab #1 and then changed the set of active dictionaries with controller in Tab #3, so now we need to get data from other db开发者_运维问答 tables. But in our Tab #1 we've got article opened and if we try to do something with it (4ex go back) it will possibly crash.
So, is there any way to reload view in Tab #1, setting it to default blank screen?
Thanks for your help.
You can use NSNotificationCenter
, see NSNotificationCenter Class Reference
In your tab 1's viewDidLoad
, add the following:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateView:) name:@"updateTab1" object:nil];
and add the following method:
- (void)updateView:(NSNotification *)notification {
/* do your updates here */
}
In your tab #3, when you want to update tab 1:
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateTab1" object:nil];
精彩评论