2

In my application I used UIActivityViewController to share text in Facebook and Twitter. But how to do different text to share? please help ..thanks in advance

I used this code:

NSString *posturl2=@"twittwrer and facebook ";


UISimpleTextPrintFormatter *printData = [[UISimpleTextPrintFormatter alloc]
                                             initWithText:@"Hi"];


NSArray *Itemsarray = @[posturl2,printData];

UIActivityViewController *activityController = [[UIActivityViewController alloc]initWithActivityItems:Itemsarray                                                                              applicationActivities:nil];


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

want like this

enter image description here

Rushi trivedi
  • 737
  • 1
  • 15
  • 37

1 Answers1

-2

Import Social Framework

#import <Social/Social.h>

Then just call

- (void)shareOnFacebookWithText:(NSString *)textToShare {
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [controller setInitialText:textToShare];
        [self presentViewController:controller animated:YES completion:nil];
    }
}

- (void)shareOnTwitterWithText:(NSString *)textToShare {

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
    {
        SLComposeViewController *tweetSheet = [SLComposeViewController
                                               composeViewControllerForServiceType:SLServiceTypeTwitter];
        [tweetSheet setInitialText:textToShare];
        [self presentViewController:tweetSheet animated:YES completion:nil];
    }
}
Taier
  • 2,109
  • 12
  • 22