Monday, January 11, 2010

Refreshing views while using a Tab Bar on the iPhone

In my tab bar based iPhone application I had a view that would connect to a web service and pull down the requested data. It would then use that data to populate labels and text fields on other views. I had it working for the first time using "- (void)viewDidLoad", but was not able to get it to update when I would go back to the main view and refresh the information.

I finally found that the viewWillAppear method just didn't have a place holder but I could add it and use it. So, just add the following code to the .m file controlling your view and it will update every time you switch back to it.

- (void)viewWillAppear:(BOOL)animated {

// Do stuff here

[super viewWillAppear:animated];


No comments: