My App creates PDF reports and I would like to enable the user to add the PDF to iBooks and send it by email. (Note, the PDF is generated online and downloaded to the App).
I tried following the example provided here: http://stackoverflow.com/questions/37990711/use-of-uiactivityviewcontroller-and-uiactivityitemprovider-to-share-pdf
First the file is downloaded and it is then shared using UIActivityViewController from iOSKit:
[code] //create the view controller
using Extensions
using Foundation
using UIKit
dim controller as UIActivityViewController
//create the controller -> create a single item array with an nsobject representing the image
//the second parameter is an NSArray of custom UIActivity objects, just pass nil since custom object
//UIActivity creation is difficult in xojo
//Try with NSData but it fails
Dim data As NSData = NSData.DataWithContentsOfFile(file.path) //file is a xojo.io.Folderitem in the View
Dim fileArr As NSArray = NSArray.CreateWithObject(data)
controller = new UIActivityViewController(fileArr, nil)
//present with nil completion handler
self.PresentViewController(controller, True, nil) //Crashes after this line[/code]
But the App crashes as soon as the UIActivityViewController is supposed to be presented.
Example project: https://www.dropbox.com/s/58744avxf1zt06l/pdfTest.xojo_binary_project?dl=0