objective-c - 如何从选定的 Twitter 帐户发送推文

标签 objective-c ios cocoa-touch 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];

最佳答案

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

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

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

此外,如果有多个帐户,Tweet Composer 应该可以选择使用哪个 Twitter 帐户。

关于objective-c - 如何从选定的 Twitter 帐户发送推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11651913/

相关文章:

ios - [[UIApplication sharedApplication] currentUserNotificationSettings].types 的调用总是返回 UIUserNotificationTypeNone

ios - TabBarController -> NavigationController -> 使用 Storyboard 的多个 UIViewController( Root View Controller )

ios - 如何使用 XCTAssertEqual 与可选模型属性进行比较

iphone - iOS:如何允许所有手势/事件*有几个异常(exception)*通过顶级 View 传递到其 subview

objective-c - 双括号方法语法。

ios - iOS 12 上不显示图标字体

iphone - 在 iPhone map 上绘制路径

objective-c - 废弃内存和内存泄漏有什么区别?

ios - 如何在 launchScreen 之后建立引导?

ios - UISplitViewController 中的导航 Controller 为底栏留出空间