Share Button in Xamarin

Hey guys,

any tips on how to bring up the share function on button click on Xamarin.IOS?

Thanks

Posts

  • StephanSchmidtStephanSchmidt DEMember ✭✭
    edited November 2014

    @DannyC That is not what i meant. I just want to bring up that share function. like the share button in, for example, safari, i just want to bring up a dialog that gives the user the option to share a link per email / Facebook.

  • ShailDShailD USMember ✭✭
    edited December 2014

    @StephanSchmidt‌ Check out Xamarin's Xamarin.Social component.

  • rmaciasrmacias USBeta, University ✭✭✭✭✭
    edited December 2014

    You want to look at the UIActivityViewController. So something like this:

    var activitiesItems = new NSString[]
    {
             (NSString)("A string I want to share with Facebook, or whatever app that is compatible with strings")
    };
    
    var activityController = new UIActivityViewController( activitiesItems, null);
    PresentViewController(activityController, true, null);
    
  • edited July 2016

    @rmacias said:
    You want to look at the UIActivityViewController. So something like this:

    var activitiesItems = new NSString[]
    {
             (NSString)("A string I want to share with Facebook, or whatever app that is compatible with strings")
    };
    
    var activityController = new UIActivityViewController( activitiesItems, null);
    PresentViewController(activityController, true, null);
    

    Thanks @rmacias , but this line:

    PresentViewController(activityController, true, null);

    It is not working for me, i get this error:

    Error CS0103: The name `PresentViewController' does not exist in the current context (CS0103)

    I have tried with this too:

    UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(activityController, true, null);

    But without luck, because this do nothing, nothing happen on button touch : /

  • NinjaFocksNinjaFocks USMember ✭✭

    @JorgeWanderSantanaUrena.2443 you need to inherit from UIActivityViewController then the method will work.

Sign In or Register to comment.