我已經在我的應用程序的日期選擇器中設置了初始日期。如果我更改了值並選擇了它,但是當選擇值而不是更改微調器時,它顯示的值是今天的日期。UIDatePicker第一個值集合不是默認讀取
我一直在嘗試使用[UIDatePicker setDate:]方法,但是我遇到問題,它不會設置。這是我的「選擇」的日期(分配到一個按鈕動作)代碼:
- (IBAction)backToMap:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
FirstViewController *fvc = [storyboard instantiateViewControllerWithIdentifier:@"FirstViewController"];
fvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
datePicked = [datePicker date];
self.firstViewData = fvc;
fvc.passedData = datePicked;
// if isPickerType = 1 then it is date and time
// if isPickerType = 2 then it is just date
fvc.datePicker = isPickerType;
[self presentViewController:fvc animated:YES completion:nil];
}
你在哪裏設定日期? – Wain
我想在'viewDidLoad'方法中設置初始日期(避免發生問題的變量) –