ios - 没有为 UIDocumentPickerViewController 调用 didPickDocumentsAtURLs 委托
问题描述
我正在尝试使用 UIDocumentPickerViewController 并且需要针对 iOS 11.0 及更高版本的应用程序。我正在模拟器中测试 iOS 版本 11.0、12.0 和 13.4 委托方法 didPickDocumentsAtURLs 在 11.0 和 12.0 上未调用,但在 13.4 版本的 iOS 上调用。在所有情况下都会调用 documentPickerWasCancelled。
这是可以重现该问题的最小代码。我有一个只有一个按钮的主视图,下面定义了按钮点击处理程序。
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)documentPicker:(UIDocumentPickerViewController *)controller
didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
}
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
}
- (IBAction)buttonTapped:(id)sender {
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
[self presentViewController:documentPicker animated:YES completion:nil];
}
@end
更新:这被称为 iCloud 驱动器文件,但不是本地文件。
解决方案
推荐阅读
- swift - 在 iOS 15 中调整 tableView 单元格内容配置中的图像内容模式
- c# - C# 百分比计算突然变为负数
- ruby-on-rails - rails中每个项目的表格
- wireshark - 从网页操作中获取请求 URL
- discord.js - 如果有使用 discordjs 的用户,请获取有关我的用户
- excel - 使用 SUMIF 时 Excel 中的奇怪总和
- c++ - Lambda 捕获与参数 - 任何性能差异?
- ffmpeg - 在FFmpeg中查找后获取帧显示编号的公式
- python - DateTimeInput() 小部件在日期和时间之间放置一个随机 T,导致 ValidationError
- ruby-on-rails - 如果哈希值是字符串,Ruby/Rails 返回哈希元素