通过打开iCalendar(.ics)文件在iOS5 Calendar中创建新事件

时间:2012-04-11 09:20:22

标签: ios ipad calendar

根据Apple's iOS 4.2 release notes

  

日历现在可以直接导入.ics文件作为添加事件的方式。如果   您的应用可以访问.ics文件,您应该测试导入它们   使用UIDocumentInteractionController API。

我正在使用.ics打开示例UIDocumentInteractionController文件并显示iOS日历应用,但它尚未创建新约会 - 它只显示日历应用中显示的内容最后一次使用。有没有人有幸以这种方式创造新事件?

UIDocumentInteractionController用法的代码是:

- (void)openDocumentIn {    
    NSString * filePath = 
    [[NSBundle mainBundle] 
     pathForResource:@"testevent" ofType:@"ics"];    

    self.documentController = 
        [UIDocumentInteractionController 
         interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];

    self.documentController.delegate = self;

    [self.documentController presentOpenInMenuFromRect:CGRectZero
                                           inView:self.view 
                                         animated:YES];
}

我的样本.ics文件:

BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
DTSTART:20120411T090000
DTEND:20120411T100000
SUMMARY:Crazy party
LOCATION:Windsor Bouncy Castle
DESCRIPTION:Lots of good stuff will happen.
PRIORITY:3
END:VEVENT
END:VCALENDAR

我在原版iPad上运行iOS 5.1。

更新

我已尝试在我的日历中预先创建一个与.ical事件的时间/数据相匹配的事件,以查看在这种情况下,日历应用程序是否至少会显示已匹配的已存在事件,但又没有运气 - 日历应用程序只是打开,显示上次显示的内容。

0 个答案:

没有答案
相关问题