1

In iOS 7 I want to share something it brings up an action sheet similar to this:

enter image description here

my code is:

NSString *textToShare = @"your text";
UIImage *imageToShare = [UIImage imageNamed:@"yourImage.png"];
NSArray *itemsToShare = @[textToShare, imageToShare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll]; //or whichever you don't need
[self presentViewController:activityVC animated:YES completion:nil];

But i'm getting blank like this:

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Goutham
  • 181
  • 9
  • check this:-http://stackoverflow.com/questions/17961932/uiactivityviewcontroller-with-text-and-mail-only/17961998#17961998 – Nitin Gohel Apr 25 '14 at 09:32
  • It's working but i'm getting only copy. i want to get facebook,twitter,mail and message. @NitinGohel – Goutham Apr 25 '14 at 09:48
  • Did you try this on an actual device rather on a simulator? Note that some of those apps aren't there on the simulator. If you have test in a device (and it has Facebook, twitter installed), then it will show up in the activityviewcontroller. – GenieWanted Apr 25 '14 at 09:48
  • yes. I tested this sample in device. That device have facebook and twitter apps. But there is also i'm getting only copy. – Goutham Apr 25 '14 at 09:53
  • Make sure imageToShare is not nil – Sunny Shah Apr 25 '14 at 09:55
  • imageToShare is not nil. now i'm getting "save image", "Assign to contact" and "copy". – Goutham Apr 25 '14 at 10:06
  • Are you logged in, via the `settings app`, on twitter and facebook? Because just having the app installed makes not differance, you need to login via the `settings.app` – rckoenes Apr 25 '14 at 10:08
  • `[activityVC setExcludedActivityTypes:[NSArray arrayWithObjects: UIActivityTypeMail,UIActivityTypeMessage,UIActivityTypePostToFacebook,UIActivityTypePostToTwitter,nil]];` I'm using this code. – Goutham Apr 25 '14 at 10:09
  • yes. I logged in twitter and facebook via settings. @rckoenes – Goutham Apr 25 '14 at 10:10
  • You may have to transform the image to `NSData`? – Larme Apr 25 '14 at 10:13
  • @Goutham in the code you posted you excluded twitter and facebook:`UIActivityTypePostToFacebook,UIActivity‌​TypePostToTwitter` thus they will not show up. – rckoenes Apr 25 '14 at 10:20
  • so now what i will do. how to post to twitter and facebook via UIActivityViewController. – Goutham Apr 25 '14 at 10:24
  • Don't include the service your want in the array that you set in the `setExcludedActivityTypes:`. This is an array of activity types you **don't** want to be available, aka excluded. – rckoenes Apr 25 '14 at 10:32

0 Answers0