0
嗨,大家好,我有一個問題設定日期選擇器
我我的代碼設置與今天的日期日期選擇器,之後,如果用戶改變選擇器我設置一個報警的日期響選擇器。
如何在這些日期「阻止選取器」?
這裏我的代碼,我希望在您的幫助下
NSDate *pickerDate = [NSDate date];
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
// Divisione della data in fattori
NSDateComponents *dateComponents = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit)
fromDate:pickerDate];
NSDateComponents *timeComponents = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit)
fromDate:pickerDate];
// Set Up dell'alarme considerando tutti i fattori
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setDay:[dateComponents day]];
[dateComps setMonth:[dateComponents month]];
[dateComps setYear:[dateComponents year]];
[dateComps setHour:[timeComponents hour]];
[dateComps setMinute:[timeComponents minute]];
//Notifica in meno di un minuto
[dateComps setSecond:0];
NSDate *itemDate = [calendar dateFromComponents:dateComps];
[dateComps release];
[alarmDatePickerUno setDate:itemDate animated:YES];
[alarmDatePickerDue setDate:itemDate animated:YES];
}
// ALARM UNO
// Set Allarme Uno
-(IBAction)setAlarmUno:(id)sender{
NSLog(@"picker in allarme");
NSCalendar *currentCalendar = [NSCalendar currentCalendar];
//Setting dell'allarme in base al picker
AlarmDateUno = [alarmDatePickerUno date];
NSLog(@"allarme settata alle");
NSLog(@"%@", AlarmDateUno);
謝謝,但這不是我所尋找的,阻止用戶交互,不要阻止日期選擇器在鬧鐘日期。 – Acunamatata 2012-04-06 04:55:28
也許我需要明白'block'的含義。你想改變日期選擇器的日期,還是你想爲選擇器設置一個不可更改的日期。我不確定我瞭解你。 – 2012-04-06 09:50:42
好吧,我嘗試用我可憐的英語解釋,我希望日期選擇器在設置鬧鐘後停留在鬧鐘的日期,並且在用戶移動它之前不要更改。 – Acunamatata 2012-04-06 10:02:13