如何在iOS中使用SLComposeViewController回复twitter帖子?

时间:2014-12-12 17:44:56

标签: ios twitter slcomposeviewcontroller

我目前正致力于将twitter集成到我的应用程序,我尝试做一些关于回复twitter post的研究。我知道如何使用SLRequest做它但没有UI。所以,我想使用SLComposeViewController ui进行回复。你们有什么建议吗?谢谢!

1 个答案:

答案 0 :(得分:0)

如果要回复特定的推文,请在此处查看此答案:Is there a way of replying to a particular tweet via SLComposerViewController

因此,除了使用SLComposeViewController之外,您还需要传递一些其他参数,包括“in_reply_to_status_id”。以上链接详细解释了这一点。

您希望回复按钮触发如下内容:

-(IBAction)TweetPressed{
  if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
  {
      SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
      [tweetSheet setInitialText:@"@USERNAME_TO_REPLY_TO"];
      [self presentViewController:tweetSheet animated:YES completion:nil];

  }
  else
  {
      UIAlertView *alertView = [[UIAlertView alloc]
                                initWithTitle:@"Sorry"
                                message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"
                                delegate:self
                                cancelButtonTitle:@"OK"
                                otherButtonTitles:nil];
      [alertView show];
  }
}

这里有完整的教程:http://ios-blog.co.uk/tutorials/integrating-social-media-in-your-apps/