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