iOS 5 中不会设置 EKAlarm
我编写了以下代码片段来创建一个事件。设置闹钟在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有同样的错误。
问题似乎是 startDate 不应该与 endDate 相同......真是愚蠢的 iOS 更改!
I had the same error.
The problem seems that startDate shoudln't be the same as endDate... really silly iOS change!
这似乎与此票证中发生的情况有关: 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.
避免操纵警报数组。您需要向您的活动添加闹钟,如下所示:
这将在开始时间前 5 分钟添加提醒。
Avoid manipulating the alarms array. You need to add the alarm to your event like this:
This will add a reminder 5 minutes before the start time.