ios - ACAccountStore 在设备上返回空数组,但在模拟器上工作

标签 ios cocoa-touch twitter slrequest

我正在开发一个应用程序,我想使用 SLRequest 向 Twitter 发布内容。我已经让它在模拟器上工作,但它在我的设备上不起作用。

 [self.accountStor accountsWithAccountType:accountTypeTwitter];

在我的设备上返回一个空数组,但它在模拟器上显示正确的帐户。我不知道为什么会发生这种情况。

我有一种方法可以获取用户的 Twitter 帐户。它看起来像这样:

- (void)fetchTwitterAccounts
{
    if (self.accountStore == nil) {
        self.accountStore = [[ACAccountStore alloc] init];
    }

    ACAccountType *accountTypeTwitter = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    self.twitterAccounts = [self.accountStore accountsWithAccountType:accountTypeTwitter];
    [self.tableView reloadData];
}

关于为什么我在我的设备上没有任何帐户有什么想法吗?

最佳答案

您有 Twitter 帐户并且该应用已获授权在您的设备上使用它们?在尝试获取帐户列表之前,您是否调用 requestAccessToAccountsWithType

检查下面的示例,如何通过首先请求访问权限并且仅在检索帐户列表的用户授予访问权限的情况下检索帐户列表

https://dev.twitter.com/docs/ios/making-api-requests-slrequest (特别是第 32-42 行)。

关于ios - ACAccountStore 在设备上返回空数组,但在模拟器上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16124901/

相关文章:

ios: [tableView reloadData]

ios - UITableview 在重新加载时滚动到顶部太高了吗?

ios - Swift SpriteKit touchesBegan 检测右/左

ios - 是否可以在 cocoa touch 中找到用户发送短信的号码?

ios - 带标签栏 Controller 的导航 Controller ?

iphone - 如何在循环遍历字符时将字符显示到 UILabel?

iphone - 如何在我没有子类化的 UITabBarController 上隐藏 UITabBar?

swift - 请求失败 : forbidden (403) after adding the provided url from Firebase in the callback settings of the Twitter app

python - 一分钟后无法停止串流播放

twitter - 如何使用 tweepy 收听 @mention 的新推文?