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;
}

浙公网安备 33010602011771号