The iOS Human Interface Guidelines say:
Use the system-provided Share button. Users are familiar with the meaning and behavior of thi
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:YES completion:nil];
}