UIDocumentPickerViewControlle i

2022-11-18  本文已影响0人  幻影道哥

1.模态打开系统自带的系统文件 选取文件
UIDocumentPickerViewController *documentPickerVC = [[UIDocumentPickerViewController alloc] initWithURL:[NSURL fileURLWithPath:fullPath] inMode:UIDocumentPickerModeExportToService];
// 设置代理
documentPickerVC.delegate = self;
// 设置模态弹出方式
documentPickerVC.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentViewController:documentPickerVC animated:YES completion:nil];

2.获取沙盒路径
// 获得文件沙盒地址

3.文件写入制定的路径
BOOL downResult = [fileData writeToFile:fullPath atomically:YES];

  1. UIDocumentPickerDelegate的代理方法

pragma mark - UIDocumentPickerDelegate

// [self dismissViewControllerAnimated:YES completion:NULL];
}];
[urls.firstObject stopAccessingSecurityScopedResource];
} else {
// 授权失败
}
}

上一篇 下一篇

猜你喜欢

热点阅读