如何在ios中的开始日期和结束日期之间不活动本地通知

时间:2016-05-26 12:31:18

标签: ios objective-c

  1. 我想在开始日期到结束日期之间停止本地通知。
  2. 以下是我为每日本地通知撰写的一段代码:

    UILocalNotification *localNotif11 = [[UILocalNotification alloc] init];
    localNotif11.alertBody = @"Hello";
    localNotif11.alertTitle=@"Reminder";
    localNotif11.soundName=@"notification.caf";
    NSDateComponents *components11 = [[NSCalendar currentCalendar]   components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitWeekOfMonth)   fromDate:[NSDate date]];
    [components11 setHour:11];
    [components11 setMinute:00];
    localNotif11.fireDate = [[NSCalendar currentCalendar]   dateFromComponents:components11];
    localNotif11.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
    
    NSLog(@"%@",localNotif11.fireDate);
    [localNotif11 setRepeatInterval:NSCalendarUnitDay];
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif11];
    

1 个答案:

答案 0 :(得分:1)

试试这段代码:

id

你在现在直到约会时才会被激怒。