2015-10-01 150 views
1

在以前的iOS中,我使用此代码和UIDocumentInteractionController从我的应用程序,与另一个应用程序打开文件。从iOS 9开始,UIDocumentInteractionController出现在屏幕上,我选择“复制到”选项,但没有任何反应。我该如何解决这个问题?iOS 9 UIDocumentInteractionController不会打开文件与应用程序

NSURL *URL = [NSURL fileURLWithPath:path];  
if (URL != nil) { 
    // Initialize Document Interaction Controller 
    documentController = [UIDocumentInteractionController interactionControllerWithURL:URL]; 

    documentController.delegate = self; 
    [documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; 
} 

回答

0

你必须管理的开放你的响应时间: -

-(void)exportToDropBox{ 
    [self performSelector:@selector(presentImagePicker) withObject:nil afterDelay:1.0]; 

} 
-(void)presentImagePicker{ 

    NSURL *targetURL = [NSURL fileURLWithPath:exportedPdfFileName]; 
    [self presentDocumentWithURL2:targetURL]; 

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

- (void)presentDocumentWithURL2:(NSURL*)url { 
    self.documentController = [UIDocumentInteractionController interactionControllerWithURL:url]; 
    self.documentController.delegate = self; 
    [self.documentController presentOpenInMenuFromRect:CGRectMake(self.view.frame.size.width/2 - 49/2, self.view.frame.size.height-49, 49, 49) inView:self.view animated:YES]; 
} 

- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller { 
    self.documentController = nil; 
} 
相关问题