【问题标题】:How to send a tweet from selected twitter account如何从选定的 Twitter 帐户发送推文
【发布时间】:2012-07-24 00:19:24
【问题描述】:

在我的应用程序中,我想显示所有 Twitter 帐户列表,并允许用户选择其中一个来发送推文。如何从选定的帐户发送推文?可能吗?这是我的代码。我发送数据,但它总是使用第一个帐户...

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
ACAccount *twitterAccount = [[accountStore accountsWithAccountType:accountType] objectAtIndex:0];
NSString *userName = [twitterAccount username];
NSLog(@"%@", userName);
TWTweetComposeViewController *twitter =
[[TWTweetComposeViewController alloc] init];
[twitter setInitialText:@"Hello"];
[twitter addURL:[NSURL URLWithString:_baseUrl]];
[tableViewController presentViewController:twitter animated:YES completion:nil];

【问题讨论】:

  • 我必须为此 +1 以表示出色,但不小心使用了“twit”
  • ontopic:@Radislav,到目前为止你尝试了什么?纯粹的代码编写请求在 Stack Overflow 上是题外话——但我们很乐意帮助您自己编写!告诉我们what you've tried,以及您遇到的问题。

标签: objective-c ios cocoa-touch twitter


【解决方案1】:

你总是选择第一个帐户的原因是因为你有这个:

ACAccount *twitterAccount = [[accountStore accountsWithAccountType:accountType] objectAtIndex:0];

您为什么还要为用户选择帐户?您应该让用户决定他们想从哪个帐户发送推文。

此外,如果有多个帐户,推文编辑器应该可以选择使用哪个 Twitter 帐户。

【讨论】:

  • 我选择第一个帐户只是为了测试。是的,这正是我想要的。谢谢,WrightsCS;)
猜你喜欢
  • 2014-10-24
  • 1970-01-01
  • 2020-04-16
  • 1970-01-01
  • 2018-02-25
  • 2011-09-18
  • 1970-01-01
  • 2012-09-05
  • 2012-12-12
相关资源
最近更新 更多