2

I have integrated the below code for the Facebook and Twitter buttons.

I currently have test images there to post in the social media sheets - however i want to post the current app screen not a pre determined image as the screen changes all the time.

What can i do?

- (IBAction)postToTwitter:(id)sender {
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
    {
        SLComposeViewController *tweetSheet = [SLComposeViewController
                                               composeViewControllerForServiceType:SLServiceTypeTwitter];
        [tweetSheet setInitialText:@"Test Run!"];
        if (![tweetSheet addImage:[UIImage imageNamed:@"test1.jpg"]]) {
            NSLog(@"Unable to add the image!");
        }

        if (![tweetSheet addURL:[NSURL URLWithString:@"http://twitter.com/"]]){
            NSLog(@"Unable to add the URL!");
        }

        [self presentViewController:tweetSheet animated:YES completion:nil];
    }
}

- (IBAction)postToFacebook:(id)sender {
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [controller setInitialText:@"Test Run"];
        [controller addURL:[NSURL URLWithString:@""]];
        [controller addImage:[UIImage imageNamed:@"test2.jpg"]];

        [self presentViewController:controller animated:YES completion:Nil];
    }
Raptor
  • 53,206
  • 45
  • 230
  • 366

0 Answers0