3

我想将 a 的重复间隔自定义为UILocalNotification一周中的某些天。我还没有找到任何有关此的信息。

如何对一周中某些天的通知重复间隔进行编程,例如,在星期日、星期一和星期五重复通知?

4

2 回答 2

4

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

于 2011-12-20T04:43:26.517 回答
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);
于 2011-12-20T04:56:17.897 回答