如何从选择的 Twitter 账户发送推文

3

在我的应用程序中,我希望展示所有的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];

我必须为“twit”的精彩而无意的使用+1。 - James Webster
2
@Radislav,你目前尝试了什么?在Stack Overflow上,纯粹的代码编写请求是不相关的 - 但我们很乐意帮助你自己编写!告诉我们你尝试了什么,以及你卡在哪里了。 - Hans Z
1个回答

2
你总是选择第一个账户的原因是因为你有这个:
ACAccount *twitterAccount = [[accountStore accountsWithAccountType:accountType] objectAtIndex:0];

为什么要为用户选择账户呢?应该让用户自己决定从哪个账户发送推文。如果有多个账户,推文编辑器应该提供选择使用哪个Twitter账户的选项。

我选择第一个账户只是为了测试。是的,这正是我想要的。谢谢,WrightsCS;) - Radislav

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接