【问题标题】:How to pick pdf files in file manager?如何在文件管理器中选择 pdf 文件?
【发布时间】:2015-03-27 04:49:18
【问题描述】:

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

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

    }

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

【问题讨论】:

标签: ios file-upload filepicker


【解决方案1】:

试试这个

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

【讨论】:

  • 这里是哪种数据类型的pdf变量?
  • CGPDFDocumentRelease(pdf);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-05-24
  • 2015-12-27
  • 2017-03-21
  • 1970-01-01
  • 2021-07-26
  • 2010-09-24
  • 2023-03-13
相关资源
最近更新 更多