iOS 5 中不会设置 EKAlarm

发布于 2024-12-09 15:53:49 字数 380 浏览 6 评论 0原文

我编写了以下代码片段来创建一个事件。设置闹钟在 iOS 4 中工作正常,但在 iOS 5 中则无法设置。 这是一个错误还是我错过了什么?

EKCalendar *cal = [self.eventStore defaultCalendarForNewEvents];
EKEvent *event = [EKEvent eventWithEventStore:self.eventStore];
event.calendar = cal;
// .......
EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:-3600];
event.alarms = [NSArray arrayWithObject:alarm];
// .......

I wrote the following snippet to create an event. Setting the alarm works fine in iOS 4, but in iOS 5 it doesn't get set.
Is this a bug or am I missing something?

EKCalendar *cal = [self.eventStore defaultCalendarForNewEvents];
EKEvent *event = [EKEvent eventWithEventStore:self.eventStore];
event.calendar = cal;
// .......
EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:-3600];
event.alarms = [NSArray arrayWithObject:alarm];
// .......

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吻风 2024-12-16 15:53:49

我有同样的错误。

问题似乎是 startDate 不应该与 endDate 相同......真是愚蠢的 iOS 更改!

I had the same error.

The problem seems that startDate shoudln't be the same as endDate... really silly iOS change!

疯狂的代价 2024-12-16 15:53:49

这似乎与此票证中发生的情况有关: EventKit - 添加带有 2 个警报的 EKEvent 时应用程序冻结 (iOS 5)

如果您查看 iOS 5 相对于 iOS 4.3 的更改文档中的 EventKit 部分,它会提到 EKEvent 已弃用某些项目。层次结构已更改,并添加了新的抽象超类: EKCalendarItem

It seems to be related to that's happening in this ticket: EventKit - App freezes when adding an EKEvent with 2 alarms (iOS 5).

If you take a look at the EventKit section in the iOS 5 changes from iOS 4.3 document, it mentions that some items are deprecated for EKEvent. The hierarchy has changed and a new abstract superclass has been added: EKCalendarItem.

岁月蹉跎了容颜 2024-12-16 15:53:49

避免操纵警报数组。您需要向您的活动添加闹钟,如下所示:

EKAlarm *reminder = [EKAlarm alarmWithRelativeOffset:-300];
[event addAlarm:reminder];

这将在开始时间前 5 分钟添加提醒。

Avoid manipulating the alarms array. You need to add the alarm to your event like this:

EKAlarm *reminder = [EKAlarm alarmWithRelativeOffset:-300];
[event addAlarm:reminder];

This will add a reminder 5 minutes before the start time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文