要从 url 加载 .ics 文件,我使用如下打开 url 的方法
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullURL]];
它工作正常。 但我想从没有 URL 的应用程序包中加载 .ics 文件。例如,我的文件是 test.ics 文件我如何加载这个文件,我们可以在没有 URL 的情况下加载它吗?
最佳答案
你可以在本地加载ics
文件
NSURL *path = [[NSBundle mainBundle] URLForResource:@'icsName' withExtension:@'ics'];
[[UIApplication sharedApplication] openURL:path];
- (IBAction)displayICS:(id)sender
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"ics"];
NSURL *url = [NSURL fileURLWithPath:path];
UIDocumentInteractionController *dc = [UIDocumentInteractionController interactionControllerWithURL:url];
dc.delegate = self;
[dc presentPreviewAnimated:YES];
}
-(UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
关于ios - 加载 .ics 文件以从应用程序添加日历事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25441961/