1

So I'm testing out Apple's new Document Provider extension. I'm trying to open up a UIDocumentMenuViewController up, and that part is working. But when I try to click on one of the items it presents, it just cancels the action sheet. This happens even when I click on the iCloud item, which is there by default. My code for presenting the controller is as follows:

let type_data = kUTTypeData.__conversion()
let documentMenuViewController = UIDocumentMenuViewController(documentTypes:   [type_data], inMode: UIDocumentPickerMode.Import)
navigationController.presentViewController(documentMenuViewController, animated: true, completion: nil)

Anyone know why this is happening?

arcticmatt
  • 1,956
  • 1
  • 19
  • 36

2 Answers2

3

You need to set the delegate on the UIDocumentMenuViewController. Then implement the -documentMenu:didPickDocumentPicker: delegate method. Then you can go ahead and present the documentPicker that was selected.

func documentMenu(documentMenu: UIDocumentMenuViewController!, didPickDocumentPicker documentPicker: UIDocumentPickerViewController!) {
    documentPicker.delegate = self
    self.presentViewController(documentPicker, animated: true, completion: nil)
}

There is a simple example of this here in Apple's guide.

Derrick Hathaway
  • 1,087
  • 11
  • 14
0

Take a look at the NewBox Apple sample code and you'll see the step you are missing. Can't provide the actual answer here as iOS 8 is still under NDA.

David Knight
  • 763
  • 6
  • 12