6

根据Apple 的 iOS 4.2 发行说明

日历现在可以直接导入 .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事件,看看在这种情况下日历应用程序是否至少会显示已经存在的匹配事件,但同样没有运气 - 日历应用程序只是打开显示上次显示的内容。

4

0 回答 0