是否可以使用iOS5中的Twitter API发送照片?

时间:2012-08-27 11:44:16

标签: iphone ios ipad twitter

  

可能重复:
  iOS 5 Attach photo to Twitter with Twitter API

一些Twitter客户端有照片推文功能。 iOS 5 Twitter API是否也包含推特照片的方式?

3 个答案:

答案 0 :(得分:2)

阅读本文:TWTweetComposeViewController Class Reference 和 - addImage属性

答案 1 :(得分:1)

需要使用TWTweetComposeViewController类参考

请参阅ios-5-attach-photo-to-twitter-with-twitter-api链接以获取代码。

答案 2 :(得分:1)

当然可以

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

        // Optional: set an image, url and initial text
        [twitter addImage:[UIImage imageName:@"YourImage.png"]];
        [twitter setInitialText:@"I created this photo Download http://www.twetter.com"];

        // 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];
        };
    }