2012-07-25 37 views
3

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

我必须+1这个辉煌,虽然意外使用“twit” – 2012-07-25 14:23:13

+2

ontopic:@Radislav,你到目前为止尝试过什么?纯粹的代码写入请求是堆栈溢出的主题 - 但我们会很乐意帮助您自己写!告诉我们[您尝试过的](http://whathaveyoutried.com),以及您卡在哪里。 – 2012-07-25 14:27:06

+0

我已更新我的问题 – Radislav 2012-07-25 14:30:44

回答

2

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

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

你为什么选择帐户用户无论如何?您应该让用户决定他们想从哪个帐户发送推文。

另外,如果有多个帐户,Tweet Composer应该有一个选项来选择使用哪个Twitter帐户。

+0

我选择第一个帐户来测试。是的,这正是我想要的。谢谢,WrightsCS;) – Radislav 2012-07-25 14:45:20

相关问题