2012-02-13 67 views

回答

2

在iOS 5中这是非常简单的。

首先添加Twitter的框架明镜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! 
    } 
... 
+0

日Thnx!那完美 – 2012-02-13 09:34:26

0

这里是所有你需要的简单代码:

-(IBAction)postTwitter:(id)sender { 

SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; 

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