4

我在 Twitter 与 IOS 的集成方面比较新

所以,我对此表示怀疑。

我在网络上的许多示例中看​​到,当您没有在 twitter 中连接帐户时,您只需显示一个警报并将用户重定向到设置以登录 twitter 帐户。

如何制作像 instagram 这样的登录表单?用户可以在哪里插入用户名和密码并提交?

我的代码现在是这样的:

accountStore = [[ACAccountStore alloc] init];
ACAccountType *twitterType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

// Request access from the user to use their Twitter accounts.
[accountStore requestAccessToAccountsWithType:twitterType options:nil completion:^(BOOL granted, NSError *error) {
      if (granted == YES){
      //get accounts to use.
      accounts = [accountStore accountsWithAccountType:twitterType];
      if ([accounts count] > 0) NSLog(@"account: %@", accounts);
      }else{
         // show alert to inser user_name and password to login on twitter
         alertTwitterAccount = [[UIAlertView alloc]
                                      initWithTitle:@"Enter with your twitter account"
                                            message:nil
                                           delegate:self
                                  cancelButtonTitle:@"Cancel"
                                  otherButtonTitles:@"Login", nil];
         [alertTwitterAccount setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
         [[alertTwitterAccount textFieldAtIndex:0] setPlaceholder:@"User"];
         [alertTwitterAccount setDelegate:self];
         [alertTwitterAccount setTag:1];
         [alertTwitterAccount show];
      }
}];

任何人都有一些例子或知道如何使用 SLRequest 或 ACAccount 来做到这一点?

谢谢

4

0 回答 0