IOS Share image and link with UIActivityViewController

 Note : You need set up in settings Twitter & Facebook accounts to share image
// get the image we want to share
  UIImage *shareImage = [UIImage imageNamed:@"photo.png"];
  NSURL *shareURL = [NSURL URLWithString:@"http://somewebsite.com"];
  NSArray *activityProviders = @[@"Make share style", shareImage,shareURL];
      UIActivityViewController *activityViewController = 

      [[UIActivityViewController alloc] initWithActivityItems:activityProviders  applicationActivities:nil];
// tell the activity view controller which activities should NOT appear

if (SYSTEM_VERSION_GREATER_THAN(@"7.0")) {
    activityViewController.excludedActivityTypes =       @[UIActivityTypeAddToReadingList,UIActivityTypePostToTencentWeibo,

       UIActivityTypeAirDrop,UIActivityTypePrint,  UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact];
} else {
        activityViewController.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,   UIActivityTypeAssignToContact];

}
 // display the options for sharing
activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

[self presentViewController:activityViewController animated:YES completion:nil];

Comments

Popular posts from this blog

LINUX Move and copy files using SSH

PHP Predefined Variables

Java : Variables Declaring