ios - 在 SLRequest 上处理多个 Twitter 帐户

标签 ios twitter acaccount

在使用 SLRequest 时,有一些关于在 iOS 应用程序中发推文的精彩教程。然而,他们中的大多数人只是从 Twitter 帐户中提取最后一个对象。由于 iOS 设置中可以登录多个 Twitter 帐户,开发者是否需要在发推之前提供选择帐户的选项,还是只使用默认帐户?

最佳答案

您并非“必须”为用户提供选项,但建议您这样做。

我们的一个选择是像这样的操作表:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Choose an Account" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
    for (ACAccount *acct in _accounts) {
        [sheet addButtonWithTitle:acct.username];
    }
    sheet.cancelButtonIndex = [sheet addButtonWithTitle:@"Cancel"];
    [sheet showInView:self.view];

这假设您已经将帐户加载到数组中(我将其命名为 _accounts),并且不选择最后一个对象,而是使用此代码显示所有可用帐户。

然后在您的 UIActionsheet 委托(delegate)方法中,检查按下了哪个操作表按钮:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex != actionSheet.cancelButtonIndex) {

        self.accountToUse = [_accounts objectAtIndex:buttonIndex];

    }
}

这将根据用户选择的内容设置帐户。这是样板文件,可能需要根据您访问它的位置进行一些更改,但它在很大程度上是您所需要的!

希望对您有帮助!

关于ios - 在 SLRequest 上处理多个 Twitter 帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14270670/

相关文章:

ios - Swift - 如何根据属性重新排序tableview中的所有单元格?

ios - AVSpeechSynthesizer 有问题,有解决方法吗?

ios - 将键盘输入的字母更改为其他字母并将其显示在 UITextfield 中

AngularJS - 如何通过 Oauth2 连接到 Twitter 仅应用程序身份验证?

ios - 如何在 iPhone 模拟器上重置 Twitter 访问权限

IOS : Make entire view scrollable, 不仅是 subview

java - 使用多个 Twitter4j 帐户发送多条推文(提及)

ios - ACAccountCredential 为 oauthToken 返回 null

iphone - 使用 Social Framework 时出现 Facebook 错误 ACErrorPermissionDenied(错误代码 7)

ajax - 来自常规服务器的 Twitter OEmbed URL "No-Access-Control-Allow-Origin"