让我再试一次,说得更清楚,我很抱歉。\我正试图在iOS中的照片分配应用程序中添加一个特定日期的提醒。我很希望能拿到它,这样它就会提醒他们一年的确切日期,让他们知道一年中那个时候的任务。
例如:
12月31日-新年前夜-放烟花,7月1日派对-加拿大日-拍摄庆祝活动,10月30日烟花-万圣节之前-拍摄南瓜,服装12月15日-圣诞彩灯!
等。
我已经有一个每日提醒设置,每天早上9点触发,提醒他们得到一个分配,这是打开或关闭的用户希望通过设置包中的切换开关。我还想再来一次“假日提醒”
以下是每日提醒的当前代码:
NSDateComponents *dateComponents = [calender components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit)
fromDate:currentDate];
NSDateComponents *temp = [[NSDateComponents alloc]init];
[temp setYear:[dateComponents year]];
[temp setMonth:[dateComponents month]];
[temp setDay:[dateComponents day]];
[temp setHour: 9];
[temp setMinute:00];
NSDate *fireTime = [calender dateFromComponents:temp];
[temp release];
// set up the notifier
UILocalNotification *localNotification = [[UILocalNotification alloc]init];
localNotification.fireDate = fireTime;
localNotification.timeZone = [NSTimeZone defaultTimeZone];如何将实际日期(12月31日)转换为fireDate =变量/字符串?
我希望这一点更清楚。我已经搜索过了,但一直找不到答案。谢谢
诺埃尔·切尼尔
发布于 2013-01-28 01:40:01
您只需要在创建fireTime时手动指定年份、月份和日期。
NSDateComponents *dateComponents = [calender components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit)
fromDate:currentDate];
NSDateComponents *temp = [[NSDateComponents alloc]init];
[temp setYear:2013];
[temp setMonth:12];
[temp setDay:31];
[temp setHour: 9];
[temp setMinute:00];
NSDate *fireTime = [calender dateFromComponents:temp]; // December 31st 2013 9:00
[temp release];
// set up the notifier
UILocalNotification *localNotification = [[UILocalNotification alloc]init];
localNotification.fireDate = fireTime;
localNotification.timeZone = [NSTimeZone defaultTimeZone];https://stackoverflow.com/questions/14551496
复制相似问题