1

我正在尝试在我的应用程序中开发运营商表单,在这里我正在尝试在我的应用程序中实现简历上传(文件上传)。我正在为打开文件管理器编写代码,但我不知道如何在文件管理器中选择 pdf 文件.please 任何人帮助完成这个.thanks提前。

 UIButton *button = (UIButton *)sender;
    NSURL *URL = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf"];

    if (URL) {
        // Initialize Document Interaction Controller
        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];

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

        // Present Open In Menu
        [self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES];

    }

这是我用于打开文件管理器的代码。

4

1 回答 1

0

尝试这个

 NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,            
 NSUserDomainMask, YES); 
 NSString *docsDirectory = [path objectAtIndex:0]; 
 NSString *filePath = [docsDirectory stringByAppendingPathComponent:@“sample.pdf"];
 NSURL *pdfUrl = [NSURL fileURLWithPath:filePath];
 pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
于 2015-03-27T06:27:10.023 回答