如何在iOS中打开Calendar .ics文件? [英] How can I open calendar .ics files in ios?

查看:1636
本文介绍了如何在iOS中打开Calendar .ics文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用中下载并打开.ics文件.

I am trying to download and open .ics file in my app.

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

I found few question, and here's some code I am using

// 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];

什么都没有发生.完全没有错误.寻找图书馆来实现这一目标会更容易.

Nothing at all happens. no errors at all. Would it be easier to look for a library to achieve this.

推荐答案

如果您有指向远程.ics文件的链接,请准备用于Safari的文件.

If you have a link to remote .ics file, then prepare it for Safari.

让我们假设您有一个指向iCal文件的链接:

Let's suppose that you have a link to iCal file:

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

只需在链接中添加前缀webcal://.

Just add prefix webcal:// to your link.

快速

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将在您的日历"应用中为您同步.

Safari will sync it in your Calendar app for You.

这篇关于如何在iOS中打开Calendar .ics文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆