是否有可能在目标-c中制作多个预定的LocalNotifications?
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponent = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate:[NSDate date]];
[dateComponent setYear:2014];
[dateComponent setMonth:6];
[dateComponent setDay:28];
[dateComponent setHour:10];
[dateComponent setMinute:48];
UIDatePicker *dp = [[UIDatePicker alloc]init];
[dp setDate:[calendar dateFromComponents:dateComponent]];
UILocalNotification *notification = [[UILocalNotification alloc]init];
[notification setAlertBody:@"Hello"];
//[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3]];
[notification setFireDate:dp.date];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.soundName = @"Song2.caf";
notification.applicationIconBadgeNumber = -1;
[application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];我试着重复这个过程,但是没有成功,我只是做了最后一个,所以我能做的就是一个预定的LocalNotification。
发布于 2014-06-22 20:02:40
是的。
使用
[application scheduleLocalNotification:notification];若要为每个通知对象设置通知而不是setScheduledLocalNotifications:[NSArray arrayWithObject:notification],请执行以下操作。
如果需要设置非常多的通知,可以在初始化和设置通知数组后将所有通知添加到通知数组中:
[application setScheduledLocalNotifications:[NSArray arrayWithObjects:notification1, notification2, notification3]];https://stackoverflow.com/questions/24354949
复制相似问题