In SWIFT, I am using a viewcontroller (VC2) to hold a datePicker which I get the date from and pass it back to VC1. VC1 have a button which load VC2 through segue. The problem that when I get the first date and unwindsegue back to VC1 and next I try to tap the button in VC1 again to change the date I find the datePicker date is set to Today and not the last I chosen. How can I keep the first chosen date/time in the datePicker when I next try to change it?
I mean when the datePicker is used in the same VC the date/time chosen the first time will be kept in the datePicker if you decided to change the date again.
Regards, Mohamed
I tried the following: In VC1:
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
var vc = storyBoard.instantiateViewControllerWithIdentifier("datePickerVc1") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
In VC2:
@IBAction func exit(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
}
And still the datePicker returns to its default state i.e., the date will be back to Today's date.