【发布时间】:2014-07-03 12:12:45
【问题描述】:
这是我当前的代码
NSCalendar *calendar = [NSCalendar currentCalendar]; // gets default calendar
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]]; // gets the year, month, day,hour and minutesfor today's date
[components setHour:15];
[components setMinute:4];
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [calendar dateFromComponents:components];
localNotification.alertBody = @"Come back for more new stuff!";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
我希望将触发日期设置为应用程序上次运行时间的 12 小时。
【问题讨论】:
标签: ios objective-c ios7