Eugene Trapeznikov
Eugene Trapeznikov

Reputation: 3240

Tweeting from iOS app

I have an application with one UILabel and one UIButton. How can I send the text in the UILabel to Twitter?

Upvotes: 0

Views: 588

Answers (3)

Ahmet Hayrullahoglu
Ahmet Hayrullahoglu

Reputation: 960

Here is the simple code that all you need:

-(IBAction)postTwitter:(id)sender {

SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

     [tweetSheet setInitialText:yourlabel.text];
     [self presentViewController:tweetSheet animated:YES completion:nil]; }

Upvotes: 0

Flori
Flori

Reputation: 2493

in iOs 5 it is very simple.

first add the twitter framework der Build Phases / Link Binary With Libraries Build Phases / Link Binary With Libraries

- (IBAction)yourTweetUIButtonAction:(id)sender {    
    if ([TWTweetComposeViewController canSendTweet]) {
        TWTweetComposeViewController *tweet = 
            [[TWTweetComposeViewController alloc] init];
        [tweet setInitialText:yourUILabel.text];
        [self presentModalViewController:tweet animated:YES];
    } else {
        //can't tweet!
    }
...

Upvotes: 2

Julien Duponchelle
Julien Duponchelle

Reputation: 595

You can try ShareKit: http://getsharekit.com/

Upvotes: 0

Related Questions