3
votes

I am using the below code to share the file/image to other apps using xamarin ios. But it is not working properly. No exceptions. Code executing properly. But the app list is not launching. What is an issue in below code? Do we need to do any configuration settings changes in the project?

var documentName = shortName + ".pdf";
            var ContentPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var fullFilename = Path.Combine(ContentPath, documentName);

            NSData dataToShare = NSFileManager.DefaultManager.Contents(fullFilename);
            var items = new NSObject[] { dataToShare };

            var controller = new UIActivityViewController(items, null);
            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(controller, true, null);
1
Any idea, how to get it working?Ammar Hadzic

1 Answers

1
votes

I'm using this code and it is working properly:

    var url = NSUrl.FromFilename(this.filePath);
    var item = url.Copy();
    var activityItems = new[] { item };
    var activityController = new UIActivityViewController(activityItems, null);

    float width = (float)this.PdfView.Frame.Width;
    float height = (float)this.PdfView.Frame.Height;

    UIPopoverController popoverController = new UIPopoverController(activityController);
    popoverController.SetPopoverContentSize(new CGSize(width, height), true);
    popoverController.PresentFromRect(new CGRect(0, 0, width, height), this.MainView, 0, true);