我们如何在iPhone应用程序中设置多个提醒,我必须为我的应用程序中的每个图像项目设置单独的提醒,以便用户可以从相机拍摄特定项目的图像(每日,每周或每月) ,我可以设置单个提醒,但当我尝试在我的应用程序中为另一个项目设置多个提醒时,它会覆盖所有项目的所有先前提醒。请给我任何想法。
答案 0 :(得分:0)
试试这个。
//KeyValue = used for identifying reminder
//RepeatType = NSWeekCalendarUnit or NSMonthCalendarUnit
//AlertBody = display text
-(void)setReminder:(NSDate*)date KeyValue:(NSString*)keyValue RepeatType:(NSInteger)repeatType AlertBody:(NSString*)alertBody
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = date;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif.alertBody = alertBody;
// Set the action button
localNotif.alertAction = NSLocalizedString(@"View",nil);
localNotif.soundName =UILocalNotificationDefaultSoundName;
// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"%@",keyValue] forKey:@"ReminderID"];
localNotif.userInfo = infoDict;
localNotif.repeatInterval = repeatType;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
//调用此方法设置单个通知。 //你可以根据需要设置多个