【发布时间】:2017-03-12 13:38:28
【问题描述】:
This is code
- (void)applicationDidEnterBackground:(UIApplication *)application {
// calendar1
NSCalendar * calendar1 = [NSCalendar currentCalendar];
NSDateComponents * Datecomps1 = [[NSDateComponents alloc] init];
[Datecomps1 setDay: 12];
[Datecomps1 setMonth:03];
[Datecomps1 setYear: 2017];
[Datecomps1 setHour: 23];
[Datecomps1 setMinute: 59];
NSDate *MyDate1 = [calendar dateFromComponents:Datecomps1];
[self addToSchedult:MyDate1];
}
- (void)addToSchedult:(NSDate *)date {
UIApplication* app = [UIApplication sharedApplication];
UILocalNotification* localNotifi = [[UILocalNotification alloc] init];
if (localNotifi) {
NSLog(@"date:%@",date);
localNotifi.fireDate = date;
localNotifi.timeZone = [NSTimeZone defaultTimeZone];
localNotifi.repeatInterval = 0;
localNotifi.soundName = @"";
[app scheduleLocalNotification:localNotifi];
}
}
我该怎么办?
我对本地通知有疑问。 我为日程安排和本地通知设置了两个日期, 我的约会准时工作。 但是当我每次进入后台时,这两个通知都会出现在屏幕上。 我怎样才能取消它?并且让两个本地通知只准时出现
【问题讨论】:
标签: ios objective-c notifications local schedule