2014-09-11 2 views
1

Я использую UIDocumentInteractionController для открытия документов в своем приложении. Я использовал метод ниже для предварительного просмотра файла в формате PDF: -Открытие файла UIDocumentInteractionController

- (IBAction)previewDocument:(id)sender 
{ 
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"]; 

    // Initialize Document Interaction Controller 
    self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]]; 

    // Configure Document Interaction Controller 
    [self.documentInteractionController setDelegate:self]; 

    // Preview PDF 
    [self.documentInteractionController presentOptionsMenuFromRect:down.frame inView:self.view animated:YES]; 

} 

Я прочитал, что мы можем читать файлы в приложение из другого приложения тоже по UIDocumentInteractionController.

В моем приложении, как я могу читать файлы из другого приложения, используя UIDocumentInteractionController? Как все это происходит?

ответ

2

Предварительный просмотр документа PDF и совместного использования.

Набор Метод Делегат: - UIDocumentInteractionControllerDelegate

NSURL *URL = [[NSBundle mainBundle] URLForResource:@"Your PDF Name" withExtension:@"pdf"]; 
UIDocumentInteractionController *documentInteractionController =[UIDocumentInteractionController interactionControllerWithURL:URL]; 
documentInteractionController.delegate = self; 
[documentInteractionController presentPreviewAnimated:YES]; 

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller { 
return self; 
} 

Если у вас есть какой-либо путаницы, нажмите на ссылку ниже и прочитать: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/PreviewingandOpeningItems.html