我的应用程序在 UIDocumentPickerViewController 上崩溃
My app is getting crashed on UIDocumentPickerViewController
我正在 iOS 应用程序上进行文件共享,我是 UIDocumentPickerViewController
的新手。我不知道为什么我的应用程序崩溃了。
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
应用在突出显示的行上崩溃。
以前有人做过吗?我想像下面的附件一样做
参见 Prerequisite
关于 Apple Documentation 的部分:
Before your app can use the document picker, you must turn on the
iCloud Documents capabilities in Xcode
如果这能解决您的问题,请告诉我!
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"] inMode:UIDocumentPickerModeImport];
即使设置了所有权利,当运行 在设备(不是模拟器)上时,这种情况仍然时不时发生。
迄今为止我找到的最佳解决方案是:
- 从 Xcode 停止应用程序。
- 从设备启动应用程序(点击主屏幕上的应用程序图标...)
- 在您的应用中导航,以打开
UIDocumentPickerViewController
。
- 打开后,您可以在 Xcode 中再次启动该应用程序,
UIDocumentPickerViewController
将按预期启动。
根据我的经验,在您安装 TestFlight 版本之前它会一直有效。有时您需要在重新启动后再次执行此操作 Xcode。
这看起来确实像是在设备上安装权利的错误。
(Xcode 7.2, iOS 9.2)
swift 3.0 你可以select 所有文档。
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)
我正在 iOS 应用程序上进行文件共享,我是 UIDocumentPickerViewController
的新手。我不知道为什么我的应用程序崩溃了。
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
应用在突出显示的行上崩溃。
以前有人做过吗?我想像下面的附件一样做
参见 Prerequisite
关于 Apple Documentation 的部分:
Before your app can use the document picker, you must turn on the iCloud Documents capabilities in Xcode
如果这能解决您的问题,请告诉我!
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"] inMode:UIDocumentPickerModeImport];
即使设置了所有权利,当运行 在设备(不是模拟器)上时,这种情况仍然时不时发生。
迄今为止我找到的最佳解决方案是:
- 从 Xcode 停止应用程序。
- 从设备启动应用程序(点击主屏幕上的应用程序图标...)
- 在您的应用中导航,以打开
UIDocumentPickerViewController
。 - 打开后,您可以在 Xcode 中再次启动该应用程序,
UIDocumentPickerViewController
将按预期启动。
根据我的经验,在您安装 TestFlight 版本之前它会一直有效。有时您需要在重新启动后再次执行此操作 Xcode。
这看起来确实像是在设备上安装权利的错误。
(Xcode 7.2, iOS 9.2)
swift 3.0 你可以select 所有文档。
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)