我使用UIDocumentPickerViewController保存一个文件,让它从一个临时位置移动和重命名一个文件:
UIDocumentPickerViewController* documentPicker = [[UIDocumentPickerViewController alloc] initForExportingURLs:@[theTempFileURL] asCopy:YES];
[self presentViewController:documentPicker animated:true completion:nil];
作为此过程的一部分,用户可以为文件选择新名称。如何获取用户为保存选择的文件名?
1条答案
按热度按时间l2osamch1#
想明白了我忘了为UIDocumentPickerViewController设置委托。在didPickDocumentsAtURL委托中,我可以检查控制器的模式。如果我处于UIDocumentPickerModeExportToService模式,那么传递给委托方法的URL列表就是文件保存位置的列表。