【问题标题】:programatically adding a calendar event on iPad以编程方式在 iPad 上添加日历事件
【发布时间】:2011-03-11 11:14:27
【问题描述】:

我的 iPad 上有一个按钮,单击它时,应在日历上创建一个具有特定标题和默认持续时间 30 分钟的条目。我怎样才能做到这一点 ?我已经达到了继承日历对象并且也能够读取它的地步。

问题:如何从代码中添加条目?

【问题讨论】:

  • 固定标签。 xcode 无关紧要。

标签: objective-c cocoa-touch ipad


【解决方案1】:

我从我的代码中粘贴了这个...如果您有任何困惑,请发表评论

EKEventStore *eventStore = [[EKEventStore alloc] init];

EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
event.title     = @"EVENT TITLE";
event.notes     = @"Event notes here";
event.startDate = [[NSDate alloc] init];
event.endDate   = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];

[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];  

【讨论】:

  • Saurabh,这是您为一小时仪式创建的活动吗?你是如何指定活动的标题的?
  • 在“event.title”中设置一个字符串值
  • 这里需要什么section和row变量?很抱歉打扰这些愚蠢的问题。我是新手,现在可以使用它
  • 我编辑了代码以简化事情。如果您有更多的困惑,请查看并发表评论..
  • Saurab,这里再澄清一件事。面对更多问题,在 NSString *eventDateStr decalration 中 ClubArr 是什么??
猜你喜欢
  • 2017-09-25
  • 2010-09-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多