tags:

views:

33

answers:

2

I am having the parentViewController dismiss the modal view because I want it to reload the UIPicker on the parentViewController. The code is really quite simple:

-(void)didDismissFormsView {

NSUserDefaults *profiles = [NSUserDefaults standardUserDefaults];

NSArray *array = [[NSArray alloc]initWithObjects:[profiles stringForKey:@"name1"],[profiles stringForKey:@"name2"],[profiles stringForKey:@"name3"],nil];

self.profileData = array;
[array release];

[self dismissModalViewControllerAnimated:YES];

}

..and I know that the method is being called correctly from the modal view because I commented out the last line (dismissModal....) and it wouldnt let me dismiss the view.

However, the UIPicker is not updating!!! If I reload the app then the UIPicker is updated because I am using that same code in the viewDidLoad method. Why wouldnt the exact same code be reloading it when that delegate method is called?

A: 

Because the viewDidLoad is not called more than once in the general case. Put your updating code in a viewWillAppear:animated: override.

David
But the code that I would want to trigger by calling viewDidLoad is right there in that method I have pasted above. I am just trying to update the picker which it should be doing. I literally just copied and pasted that code from the viewDidLoad section.
Rob
A: 

I figured it out, my code above was reloading the data into the array but not displaying it. As soon as I added [picker reloadAllComponents], it worked fine. The picker just needed to be reloaded.

Rob