1

アラームが1つ付いた時計アプリを作成しています。

アラームを設定するボタン、アラームをオンにするボタン、アラームをオフにするボタンがあります。

設定ボタンは、ローカル通知を使用して機能します。

UILocalNotification *scheduledAlert;
[[UIApplication sharedApplication] cancelAllLocalNotifications];
scheduledAlert = [[UILocalNotification alloc] init];
scheduledAlert.applicationIconBadgeNumber=1;
scheduledAlert.fireDate = alarmPicker.date;
scheduledAlert.timeZone = [NSTimeZone defaultTimeZone];
scheduledAlert.repeatInterval =  NSDayCalendarUnit;
scheduledAlert.soundName=@"alarm_clock_ringing.wav";
scheduledAlert.alertBody = @"I’d like to get your attention again!";
[[UIApplication sharedApplication]
                   scheduleLocalNotification:scheduledAlert];

すべてが正常に機能します。

ただし、オンボタンとオフボタンのコーディング方法がわかりません。

4

1 に答える 1

0

Off ボタンの場合は、 のようなものを使用する必要がありますCancelAllCurrentNotifications

于 2012-08-13T00:05:55.760 に答える