3

UILocalNotificationa の繰り返し間隔を特定の曜日になるようにカスタマイズしたいと考えています。これに関する情報は見つかりませんでした。

日曜日、月曜日、金曜日に通知を繰り返すなど、特定の曜日の通知の繰り返し間隔をプログラムするにはどうすればよいですか?

4

2 に答える 2

4

repeatInterval残念ながら、 のプロパティをUILocalNotification特定の日にのみ繰り返すように設定することはできません。毎日 (毎日)、毎月 (毎月)、または毎時 (毎時) のいずれかで繰り返しを設定できます。したがって、質問に対する唯一の実行可能な解決策は、日曜日、月曜日、火曜日にアラームを設定する場合、1 つのアラームではなく 3 つのアラーム (日曜日、月曜日、火曜日にそれぞれ 1 つ) を設定する必要があるということです。

于 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 に答える