我想將UILocalNotification
的重複間隔定製爲一週中的某幾天。我還沒有找到任何關於此的信息。在某周的某幾天重複UILocalNotification
如何設置一週中某些日子的通知重複間隔,例如,星期日,星期一和星期五重複通知?
我想將UILocalNotification
的重複間隔定製爲一週中的某幾天。我還沒有找到任何關於此的信息。在某周的某幾天重複UILocalNotification
如何設置一週中某些日子的通知重複間隔,例如,星期日,星期一和星期五重複通知?
不幸的是,您不能將repeatInterval
屬性UILocalNotification
僅在特定日期重複使用。您可以設置每天(每天),每月(每月)或每小時(每小時)重複一次。因此,針對您的問題唯一可行的解決方案是,如果您想在週日,週一和週二設置鬧鐘,則必須設置3次鬧鐘(週日,週一和週二各一次),而不是一次鬧鐘。
如果您需要自定義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-09 20:20:00