Have a share button IoS with all possible entities

281 views Asked by At

I am looking for a share button with all entities like FB/G+/Watsapp/Mail etc., So effectively, once the user presses the share button, a popup with all values should turn up and upon selection of the appropriate item, it should share accordingly.

Can anyone please guide through the steps to accomplish this.

2

There are 2 answers

0
danielrosero On BEST ANSWER

This goes in your viewDidLoad:

UIBarButtonItem *shareButton = [[UIBarButtonItem alloc]
                            initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                            target:self
                            action:@selector(compartir:)];
self.navigationItem.rightBarButtonItem = shareButton;

And define your selector method to be called as action (in my case named as "compartir"):

- (void) compartir:(id)sender{

//Si no


NSLog(@"shareButton pressed");


NSString *stringtoshare= @"This is a string to share";
UIImage *imagetoshare = img; //This is an image to share.

NSArray *activityItems = @[stringtoshare, imagetoshare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc]                initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact,       UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:TRUE completion:nil];
}
0
Esha On

You can check this answer for your query:Answer for activity

You need to use activity view controller for showing all possibilities which iphone can Give.