• May
  • 16
  • 2015

Code for sharing picture on Social Media in iOS

Want to add image sharing to social media button? Or having trouble in your code for picture sharing button in iOS application?

Don’t worry!

Here is the steps and code to add picture share button:

Share an image to available social media with UIActivityViewController in iOS


1. Add a button in view controller from your storyboard

2. Create a button method for your share button as follows:

UIButton *shareButton = (UIButton*)sender;
//image from project.
NSString *text = @"How to add sharing Button to your iOS app";
NSURL *url = [NSURL URLWithString:@"https://www.gurutechnolabs.com/code-for-sharing-picture-on-social-media-in-ios/"];
UIImage *imageShare = [UIImage imageNamed:@"star.png"];
NSArray *Items = [NSArray arrayWithObjects: imgShare, url, text, nil];
UIActivityViewController *ActivityView =[[UIActivityViewController alloc]initWithActivityItems:Items applicationActivities:nil];

// Exclude following activities.
NSArray *excludedActivities = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,UIActivityTypeAirDrop];
ActivityView.excludedActivityTypes = excludedActivities;
ActivityView.popoverPresentationController.sourceView= shareButton;

[self presentViewController:ActivityView animated:YES completion:nil];
Activity types are divided up into “action” and “share” types:


  • UIActivityTypePrint
  • UIActivityTypeCopyToPasteboard
  • UIActivityTypeAssignToContact
  • UIActivityTypeSaveToCameraRoll
  • UIActivityTypeAddToReadingList
  • UIActivityTypeAirDrop


  • UIActivityTypeMessage
  • UIActivityTypeMail
  • UIActivityTypePostToFacebook
  • UIActivityTypePostToTwitter
  • UIActivityTypePostToFlickr
  • UIActivityTypePostToVimeo
  • UIActivityTypePostToTencentWeibo
  • UIActivityTypePostToWeibo

3. Map above method to Touchup inside event of that button

You are done. Enjoy Sharing !!

If this blog could not answer your question then you can hire iphone app developers who will assist you to integrate social sharing in your application.

Ravi Makhija

Ravi Makhija

A writer, an Entrepreneur. Curious about the internet of everything. Interested in the cutting edge landscape of mobile apps and SAAS products. Blogs for Guru Technolabs - A Mobile App Development Company.

Let's Discuss a Project

Please share your unique idea or project requirement with us, our business concern person will get back to you with further details.