My app is getting crashed on UIDocumentPickerViewController

落爺英雄遲暮 提交于 2019-11-28 12:05:13

See Prerequisite section on Apple Documentation:

Before your app can use the document picker, you must turn on the iCloud Documents capabilities in Xcode

Let me know if this solve your problem!

Even with all entitlements set up, this still happens every now and then, when running on a device (not simulator).
The best solution I've found so far is:

  1. Stop the app from Xcode.
  2. Launch the app from the device (tap the app icon on the home screen...)
  3. Navigate in your app, in order to open the UIDocumentPickerViewController.
  4. Once open, you can launch the app again in Xcode and UIDocumentPickerViewController will init as intended.

From my experience, it will work until you install a TestFlight build. Sometimes you'll need to do this again after restarting Xcode.
This certainly looks like a bug with installing entitlements on the device.

(Xcode 7.2, iOS 9.2)

swift 3.0 you can select all document.

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)
Ketan Patel
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"] inMode:UIDocumentPickerModeImport];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!