views:

206

answers:

1

Hello I am using a tab bar application.

I want to reload a view when user presses on any of tab button.

if user presses first button of tab bar, first view is loaded only once.

i need when ever user presses first tab bar button, view must be reloaded.

this is required, due to following reason in first view - i have list of employees & in second view - i have add screen of employees

after adding an employee, it is obvious that user will click on tab bar button one to see newly added record.

but view is not loaded again,

so, i need to reload entire view

that is -viewDidLoad{ } method should be invoked every time.

please help me.

I will be thank full.

+1  A: 

Don't count on viewDidLoad getting called every time a view appears. Instead, you should move the code into viewWillAppear (or better yet, move it into a separate method and call that method from viewWillAppear).

For example:

- (void)loadEmployeeData {
    // Your code here
}

- (void)viewWillAppear {
    [super viewWillAppear];

    [self loadEmployeeData];
}

In general, you should put loading code that only needs to run once (but may run multiple times) into viewDidLoad, code that needs to run every time a view is shown in viewWillAppear or viewDidAppear, and code that can run even before the view loads or absolutely needs to only run once into initWithNibName:bundle:.

Tim