0

I have a datePicker and I want to use it as a timer. The timer should send a notification when the time is over. But i don't know how to do this, because it only works when I use the picker as a "date collector".

NSDate *date = [self.datePicker date];
...

UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;

But how should i rewrite this for a datePicker with "Count Down Timer" mode? Thanks for your response ;)

4

1 回答 1

0

添加countDownDuration来自日期选择器并将其添加到当前日期:

NSTimeInterval duration = self.datePicker.countDownDuration;
NSDate *fireDate = [NSDate dateWithTimeIntervalSinceNow:duration];

这假设您使用的是UIDatePickerinUIDatePickerModeCountDownTimer模式。

于 2013-07-14T16:33:46.890 回答