2

I am working on a game and what I want to do is take a screenshot when the player dies and upload that image using the iOS sharesheet functionality to share to twitter, facebook etc... I have the image stored locally.

Here is my code for sharing an image link, but I want to upload a local image instead.

Any help would be much appreciated.

public void Share(int score)
    {
        UIViewController rootViewController = new UIViewController();
        NSURL url = new NSURL("http://i.imgur.com/iWKad22.jpg");
        NSData data = NSData.read(url); 
        UIImage image = new UIImage(data);
        NSString textShare = new NSString("My Score: " + score + "! #Udderpanic");
        NSArray<NSObject> textToShare = new NSArray<NSObject>(textShare, image);
        UIActivityViewController share = new UIActivityViewController(textToShare,null);
        ((IOSApplication)Gdx.app).getUIViewController().addChildViewController(rootViewController); 

        if(UIDevice.getCurrentDevice().getModel().contentEquals("iPad"))
        {
            final UIPopoverController popoverController = new UIPopoverController(share);
            popoverController.presentFromRectInView(new CGRect(0, 400, 0, 400), rootViewController.getView(), UIPopoverArrowDirection.Right, true); 
        }
        else
        {
            rootViewController.presentViewController(share, true, null);
        }
      }
Michele Lacorte
  • 5,323
  • 7
  • 32
  • 54

0 Answers0