UIDocumentInteractionController的使用方法

主要用来调用系统的视图控制器从软件中挑选工具(如:word,pdf)来打开软件里面的文件

使用方法:

    NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0] stringByAppendingPathComponent:@"test.png"];

    NSURL *fileUrl = [NSURL fileURLWithPath:filePath];

    UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:fileUrl];

    documentController.delegate = self;

    [documentController presentPreviewAnimated:YES];

注意设置UIDocumentInteractionControllerDelegate

注意文件名一定要有后缀的

调用delegate方法

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller

{

    return self;

}

posted @ 2015-11-24 18:22  老茶叶  阅读(879)  评论(0)    收藏  举报