如何在iOS中的特定时间触发每日本地通知

我想获得每日通知,为此,我已经GOOGLE了,我从这个iPhone得到了一些解决scheme:每日本地通知,但我无法正确识别

NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [[NSDateComponents alloc] init]; [components setDay: 3]; [components setMonth: 7]; [components setYear: 2012]; [components setHour: 6]; [components setMinute: 0]; [components setSecond: 0]; [calendar setTimeZone: [NSTimeZone defaultTimeZone]]; NSDate *dateToFire = [calendar dateFromComponents:components]; 

假设当前时间是3:13,当前date是20-11-2014在这个我想在3:14,20-11-2014时间设置本地通知任何人都可以请帮助我,因为我试过以下的事情,但不工作

  [components setDay: 20]; [components setMonth: 11]; [components setYear: 2014]; [components setHour: 15]; [components setMinute: 14]; [components setSecond: 0]; 

  NSDate *date = [NSDate date]; NSDate *newDate1 = [date dateByAddingTimeInterval:60*60*24]; UILocalNotification *localNotif = [[UILocalNotification alloc] init]; localNotif.fireDate = newDate1; localNotif.timeZone = [NSTimeZone defaultTimeZone]; localNotif.alertBody = [[NSUserDefaults standardUserDefaults] objectForKey:@"NotificationText"]; localNotif.alertAction = @"View"; localNotif.applicationIconBadgeNumber = 1; [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 

试试这个希望这可以帮助你。 谢谢

 NSDate* now = [NSDate date] ; NSDateComponents* tomorrowComponents = [NSDateComponents new] ; tomorrowComponents.day = 1 ; NSCalendar* calendar = [NSCalendar currentCalendar] ; NSDate* tomorrow = [calendar dateByAddingComponents:tomorrowComponents toDate:now options:0] ; NSDateComponents* tomorrowAt7AMComponents = [calendar components:(NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:tomorrow] ; tomorrowAt7AMComponents.hour = 7 ; NSDate* tomorrowAt7AM = [calendar dateFromComponents:tomorrowAt7AMComponents] ; localnotification.fireDate = tomorrowAt7AM; 

我希望这可以帮助你。