在 iOS5 的 Twitter 上发布照片



我是iOS5中Twitter集成的新手。

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

我已经搜索了很多,并练习了这方面的示例教程。我只收到照片网址。我需要发布照片。

谁能帮我解决这个问题?提前谢谢。

首先,您需要保存图像,然后您可以将保存的图像发布到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];
        };
    }

最新更新