Ios 我的应用程序在UIDocumentPickerViewController上崩溃
我正在我的iOS应用程序上进行文件共享,我是Ios 我的应用程序在UIDocumentPickerViewController上崩溃,ios,xcode,icloud,icloud-drive,uidocumentpickervc,Ios,Xcode,Icloud,Icloud Drive,Uidocumentpickervc,我正在我的iOS应用程序上进行文件共享,我是UIDocumentPickerViewController的新手。我不知道为什么我的应用程序会崩溃 UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport]; documentPic
UIDocumentPickerViewController
的新手。我不知道为什么我的应用程序会崩溃
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
应用程序在突出显示的行上崩溃
以前有人这样做过吗?我想像下面的附件一样执行此操作请参见
先决条件
部分:
在应用程序可以使用文档选择器之前,必须打开
iCloud在Xcode中记录功能
让我知道这是否解决了你的问题 即使设置了所有权限,当在设备上运行(非模拟器)时,这种情况仍然时不时发生。
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"] inMode:UIDocumentPickerModeImport];
到目前为止,我找到的最佳解决方案是:
UIDocumentPickerViewController
UIDocumentPickerViewController
将按预期初始化这看起来确实像是一个在设备上安装授权的bug
(Xcode 7.2,iOS 9.2)swift 3.0您可以选择所有文档
let documentPicker = UIDocumentPickerViewController(documentTypes: ["com.apple.iwork.pages.pages", "com.apple.iwork.numbers.numbers", "com.apple.iwork.keynote.key","public.image", "com.apple.application", "public.item","public.data", "public.content", "public.audiovisual-content", "public.movie", "public.audiovisual-content", "public.video", "public.audio", "public.text", "public.data", "public.zip-archive", "com.pkware.zip-archive", "public.composite-content", "public.text"], in: .import)
documentPicker.delegate = self
present(documentPicker, animated: true, completion: nil)
请显示崩溃线程的堆栈跟踪。[UIDocumentPickerViewController _commonInitWithCompletion:],/SourceCache/UIKit_Sim/UIKit-3318.16.14/UIDocumentPickerViewController.m:66 2015-03-27 17:40:24.282 DocPick[3285:73604]***由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“初始化文档选择器的应用程序缺少iCloud权限。com.apple.developer.icloud-container-identifiers设置了吗?'***第一次抛出调用堆栈:看看这个,