2011-05-09 93 views
3

我想将UILocalNotification的重复间隔定制为一周中的某几天。我还没有找到任何关于此的信息。在某周的某几天重复UILocalNotification

如何设置一周中某些日子的通知重复间隔,例如,星期日,星期一和星期五重复通知?

+0

我有同样的问题 – 2011-12-09 20:20:00

回答

4

不幸的是,您不能将repeatInterval属性UILocalNotification仅在特定日期重复使用。您可以设置每天(每天),每月(每月)或每小时(每小时)重复一次。因此,针对您的问题唯一可行的解​​决方案是,如果您想在周日,周一和周二设置闹钟,则必须设置3次闹钟(周日,周一和周二各一次),而不是一次闹钟。

0

如果您需要自定义repeatInterval属性。您必须在指定的时间设置每个UILocalNotification。这是我的代码。


    void (^insertAlarm)(NSDate*fire,NSString*sound,int alarmCount) = ^(NSDate*fire,NSString*sound,int alarmCount){ 
     UILocalNotification* notification = [[UILocalNotification alloc] init]; 
     notification.timeZone = [NSTimeZone defaultTimeZone]; 
     notification.soundName = sound; 
     notification.fireDate = fire; 
     notification.repeatInterval = 0; 
     notification.alertLaunchImage = IMG; 
     notification.alertAction = ACTION_MSG;   
     notification.alertBody = BODY; 
     notification.applicationIconBadgeNumber = 1; 
     [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 
     [notification release]; 
    }; 

    insertAlarm(date,sound.fileName,0); 
    insertAlarm([date dateByAddingTimeInterval:60],sound.fileName,1); 
相关问题