iOS 5 Attach photo to Twitter with Twitter API

后端 未结 3 736
谎友^
谎友^ 2020-12-09 22:25

Is there any way to add a photo to Twitter timeline using TWRequest or anything like so?? I\'m very very lost in this case.

I can post a status update using TWReques

3条回答
  •  [愿得一人]
    2020-12-09 22:53

    you can use the twitter compose view controller TWTweetComposeViewController to post photos to twitter without dealing with twitter oauth and accounts. see http://developer.apple.com/library/ios/#documentation/Twitter/Reference/TWTweetSheetViewControllerClassRef/Reference/Reference.html for more details.

    The main issue is it's a new feature of iOS 5, so users that didn't upgrade won't be able to use it.

    TWTweetComposeViewController* tweetView = [[TWTweetComposeViewController alloc] init];
    [tweetView addImage:yourImage];
    
    TWTweetComposeViewControllerCompletionHandler 
           completionHandler =
        ^(TWTweetComposeViewControllerResult result) {
            switch (result)
            {
                case TWTweetComposeViewControllerResultCancelled:
                    NSLog(@"Twitter Result: canceled");
                    break;
                case TWTweetComposeViewControllerResultDone:
                    NSLog(@"Twitter Result: sent");
                    break;
                default:
                    NSLog(@"Twitter Result: default");
                    break;
            }
            [self dismissModalViewControllerAnimated:YES];
        };
    [tweetView setCompletionHandler:completionHandler];
    

提交回复
热议问题