0

可能重复:
iOS 5 使用 Twitter API 将照片附加到 Twitter

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

4

3 回答 3

2

阅读:TWTweetComposeViewController 类参考 和 -addImage 属性

于 2012-08-27T11:48:41.550 回答
1

需要使用 TWTweetComposeViewController类参考

有关代码,请参阅ios-5-attach-photo-to-twitter-with-twitter-api链接。

于 2012-08-27T11:57:37.070 回答
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];
        };
    }
于 2012-08-27T12:03:57.810 回答