我如何打开ios中的日历.ics文件?

我正试图下载并打开我的应用程序中的.ics文件。

我发现几个问题,这里是我使用的一些代码

// NSString *path = [[NSBundle mainBundle] pathForResource:@"http://www.nmsd.wednet.edu//site/handlers/icalfeed.ashx?MIID=607" ofType:@"ics"]; NSURL *url = [NSURL fileURLWithPath:@"http://www.nmsd.wednet.edu//site/handlers/icalfeed.ashx?MIID=607"]; UIDocumentInteractionController *dc = [UIDocumentInteractionController interactionControllerWithURL:url]; dc.delegate = self; [dc presentPreviewAnimated:YES]; 

没有任何事情发生。 没有任何错误。 找一个图书馆来实现这一点会更容易吗?

如果你有一个远程.ics文件的链接,然后准备用于Safari

假设你有一个链接到iCal文件:

 "pl-dev2.office.org/events/sync.ics?t=90613b6c7f8". 

只需将前缀webcal://添加到您的链接。

迅速

 let link = "webcal://pl-dev2.office/events/sync.ics?t=90613b6c7f8" let webcal = NSURL(string: link) UIApplication.sharedApplication().openURL(webcal) 

Objective-C的

 NSString *link = "webcal://pl-dev2.office/events/sync.ics?t=90613b6c7f8" NSUrl *webcal = [NSURL URLWithString:link]; [[UIApplication sharedApplication] openURL:webcal]; 

Safari会在您的日历应用程序中为您同步。