日历现在可以直接导入.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];
}
Run Code Online (Sandbox Code Playgroud)
和我的示例.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
Run Code Online (Sandbox Code Playgroud)
我在原版iPad上运行iOS 5.1.
更新
我已经尝试在我的日历中预先创建一个与事件的时间/数据相匹配的.ical事件,看看在这种情况下,日历应用程序是否至少会显示已经存在的匹配事件,但再次没有运气 - 日历应用程序只是打开显示上次显示的内容.
| 归档时间: |
|
| 查看次数: |
3244 次 |
| 最近记录: |