开发者

Delegate Methods

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:

-(v开发者_如何学JAVAoid)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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜