0

Possible Duplicate:
iOS 5 Attach photo to Twitter with Twitter API

Some Twitter clients have a photo tweet feature. Does the iOS 5 Twitter API also include a way to tweet a photo?

Community
  • 1
  • 1
Proud Member
  • 40,078
  • 47
  • 146
  • 231
  • Have you taken a look here already? http://stackoverflow.com/questions/8129079/ios-5-attach-photo-to-twitter-with-twitter-api – Nicola Miotto Aug 27 '12 at 11:46

3 Answers3

2

Read this : TWTweetComposeViewController Class Reference and the - addImage property

Pierre
  • 10,593
  • 5
  • 50
  • 80
1

There is need to use TWTweetComposeViewController Class Reference

Refer ios-5-attach-photo-to-twitter-with-twitter-api link for code.

Community
  • 1
  • 1
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
1

Yes of course

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];
        };
    }
Hiren
  • 12,720
  • 7
  • 52
  • 72
  • Great! But isn't it better to test for class or method availability rather than system version? – Proud Member Aug 27 '12 at 12:43
  • actually you have to check system version because iOS 5.0 and up version support twitter framework and below version you have to use some other API like to upload images like twitpic – Hiren Aug 27 '12 at 12:49
  • Here's an example for that check: http://stackoverflow.com/questions/8248068/is-it-possible-to-check-if-a-user-has-a-twitter-account-in-the-built-in-twitter?rq=1 – Proud Member Aug 27 '12 at 12:57
  • Glad I was able to help too :-) – Proud Member Aug 28 '12 at 12:03