0

我是 iOS5 中 Twitter 集成的新手。

我需要在 Twitter 上发布来自服务的照片。

我已经搜索了很多并且还练习了这方面的示例教程。我只得到照片 URL。我需要张贴照片。

任何人都可以帮我解决这个问题吗?提前致谢。

4

1 回答 1

0

首先,您需要保存图像,然后您可以将保存的图像发布到 Twitter

 self.shareImg.image = [UIImage imageNamed:@"Your Saved image"];

 if ([[[UIDevice currentDevice] systemVersion] floatValue] > 5.0) {
        // Create the view controller
        TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];

        NSString *str = [NSString stringWithFormat:@"I created this photo http://%@", iTune];

        // Optional: set an image, url and initial text
        [twitter addImage:self.shareImg.image];

        [twitter setInitialText:[NSString stringWithFormat:@"I created this photo using USC Project Trojan App:http://uslofphoto.com. Download http://%@", iTune]];

        // Show the controller
        [self presentModalViewController:twitter animated:YES];

        // Called when the tweet dialog has been closed
        twitter.completionHandler = ^(TWTweetComposeViewControllerResult result) 
        {
            NSString *title = @"Tweet Status";
            NSString *msg; 

            if (result == TWTweetComposeViewControllerResultCancelled)
                msg = @"Tweet compostion was canceled.";
            else if (result == TWTweetComposeViewControllerResultDone)
                msg = @"Tweet composition completed.";

            // Show alert to see how things went...
            UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
            [alertView show];

            // Dismiss the controller
            [self dismissModalViewControllerAnimated:YES];
        };
    }
于 2012-08-13T10:32:10.347 回答