2015-10-01 88 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; 
} 
相關問題