在我的应用程序中,我想显示所有 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];
最佳答案
你总是选择第一个帐户的原因是因为你有这个:
ACAccount *twitterAccount = [[accountStore accountsWithAccountType:accountType] objectAtIndex:0];
您为什么要为用户选择帐户?您应该让用户决定他们要从哪个帐户发送推文。
此外,如果有多个帐户,Tweet Composer 应该可以选择使用哪个 Twitter 帐户。
关于objective-c - 如何从选定的 Twitter 帐户发送推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11651913/