【问题标题】:Recurring alarm in iphone appiPhone应用程序中的重复警报
【发布时间】:2012-12-05 22:24:24
【问题描述】:

我正在制作一个 iphone 应用程序,其中有一个警报实现模块。在这个闹钟实现中,我必须设置闹钟,这个闹钟可以是一天中不同时间的多次,也可以是几天。我想为此使用日历 API。如何使用日历 API 设置闹钟。我该如何实现这个概念。如果有人知道这个概念。请帮帮我。

提前致谢。

【问题讨论】:

标签: iphone


【解决方案1】:

我假设您想要某种推送通知?就像一个 UIAlertView。这称为 UILocalNotification。

UILocalNotification *localNotif = [[UILocalNotification alloc]init];
[localNotif setFireDate:[NSDate dateWithTimeInterval:10.0f sinceDate:[NSDate new]]]; // the date to fire
[localNotif setAlertAction:@"Test"]; // title
[localNotif setAlertBody:@"This is a test"]; // tells you what to put in the description
[localNotif setRepeatInterval: NSWeekCalendarUnit]; // repeat interval, what you asked for
[[UIApplication sharedApplication]scheduleLocalNotification:localNotif]; // put it into the application
[localNotif release];

这会在十秒内触发通知,并从您指定的日期起每周重复一次(我相信如果我错了其他程序员,请发表评论)。

您必须使用这些选项

NSEraCalendarUnit NSYearCalendarUnit NSMonthCalendarUnit NSDayCalendarUnit NSHourCalendarUnit NSMinuteCalendarUnit NSSecondCalendarUnit NSWeekCalendarUnit NSW工作日日历单位 NSWeekdayOrdinalCalendarUnit NSQuarterCalendarUnit

【讨论】:

    【解决方案2】:

    可以是一天中不同时间的次数,也可以是几天

    这到底是什么意思?

    我也不太明白你指的是什么。

    仅供参考,看看这个:http://developer.apple.com/library/iOS/#documentation/UIKit/Reference/UIDatePicker_Class/Reference/UIDatePicker.html

    【讨论】:

    • 一天中不同时间的次数,可以是天数。
    猜你喜欢
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-29
    • 2022-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多