views:

49

answers:

1

Hi,

I have the same problem as the guy here: http://stackoverflow.com/questions/2682844/uiimagepickercontroller-reloads-view-after-its-dismissed

I have a UIView with a UIDatePicker within a Popover. When the Popover is dismissed and presented again, it sometimes resets the Picker in the view because hidden views are unloaded when a memory warning occurs.

This is the part displaying the view:

endCompareDateTimePicker.picker.maximumDate = [NSDate dateWithTimeIntervalSinceNow:0];

[endCompareDateTimePopover presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

The picker (IBOutlet UIDatePicker) does not stay initiated. Adding a [endCompareDateTimePicker loadView] helped out and got me the picker initiated to set the correct date values before displaying the view.

While this is working, I dont think this is the proper way doing this.

What would be the correct way to handle this situation?

A: 

Your above code for configuring the DatePicker should be in the -viewDidLoad method of whichever ViewController owns the date picker (ie the View Controller that manages what's inside your popup).

jbrennan
I thought so, but was not sure at that time. Thank you.
favo