2

我已经为 Facebook 和 Twitter 按钮集成了以下代码。

我目前有测试图像可以发布在社交媒体表中 - 但是我想发布当前应用程序屏幕而不是预先确定的图像,因为屏幕一直在变化。

我能做些什么?

- (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];
    }
4

0 回答 0