在应用程序中附加文档,打开文档文件夹或按钮单击列表

时间:2016-10-27 06:46:20

标签: ios objective-c xcode file-upload server

我正在开发一个基于工作门户的应用程序,现在我坚持使用文档上传,我需要在按钮点击时在设备上查找文档,并在选择时附加文档。我必须将所选文档上传到服务器。我怎样才能做到这一点 ?任何出路?

1 个答案:

答案 0 :(得分:1)

我为我的查询找到了解决方案。下面是代码。

- (IBAction)search:(id)sender {

UIDocumentMenuViewController *importMenu =
[[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[@"public.data"]
                                                     inMode:UIDocumentPickerModeImport];

importMenu.delegate = self;
[self presentViewController:importMenu animated:YES completion:nil];
[importMenu addOptionWithTitle:@"Photos" image:nil order:UIDocumentMenuOrderFirst handler:^{

    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

    imagePickerController.delegate = self;
    [self presentViewController:imagePickerController animated:YES completion:nil];
}];

}
-(void)documentMenu:(UIDocumentMenuViewController *)documentMenu didPickDocumentPicker:(UIDocumentPickerViewController *)documentPicker

{
documentPicker.delegate = self;
[self presentViewController:documentPicker animated:YES completion:nil];
 }