1

I am setting the userName label text in RootViewController in splitViewController it works fine but problem is that I want to change the userName label text in otherViewController but when I open Root Viewcontroller it does not get the new userName may be due to it does not get reloaded again.

4

1 回答 1

0

First you need to set one global variable for accessing this where you set Username from another class and then you can use bellow methods for set Username on particular variable.

you can access class method from Other class using @protocol

or

You can use NSNotificationCenter as Bellow

Add Bellow Method into your rootViewcontroller ViewDidLoad method:-

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(actionNotificationData:)
                                                 name:@"reloadData"
                                               object:nil];

-(void)actionNotificationData:(NSNotification *)notification {

   //your code for variable logic

}

and put Bellow Method for calling NSNotificationCenter where from you want to calling reloadData rootViewcontroller

[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadData" object:self];
于 2013-07-11T08:00:14.897 回答