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];

一切正常。

但是,我不知道如何编写 On 和 Off 按钮。

4

1 回答 1

0

对于关闭按钮,您必须使用类似CancelAllCurrentNotifications.

于 2012-08-13T00:05:55.760 回答