重定向到Twitter登录的设置屏幕

Gre*_*ode 3 twitter xcode objective-c ios

在Twitter中,如果用户已在设置屏幕中的Twitter帐户中登录它将允许发布.否则它将显示警报为"无Twitter帐户",其中包含2个选项"设置""取消".如果Cancel是Tapped,它将关闭警报并拒绝发布到Twitter.如果Settings是Tapped,它不会重定向到设置屏幕.我也用过

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]];
Run Code Online (Sandbox Code Playgroud)

但没有运气.据我所知,所有人都说从iOS 5.1它不会工作.但我看到一些应用程序仍然重定向到iOS7中的设置屏幕.是否可以在iOS7中重定向.提前致谢. 在此输入图像描述

Ash*_*osh 5

您可以在登录按钮的操作中使用以下代码:

if ([TWTweetComposeViewController canSendTweet])
{
    //yes user is logged in
    accountStore = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    // Request access from the user to use their Twitter accounts.
    [accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
     {
         // Did user allow us access?
         if (granted == YES)
         {
             // Populate array with all available Twitter accounts
             NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType];

             ACAccount *acct = [arrayOfAccounts objectAtIndex:0];

             // Set the cell text to the username of the twitter account
             NSString *userID = [[acct valueForKey:@"properties"] valueForKey:@"user_id"];
             TwitterIdStr = [[NSString alloc] initWithString:userID];
             FbIdStr = [[NSString alloc] init];
             NSLog(@"%@",userID);
             NSString *networkCheck = [[NSUserDefaults standardUserDefaults] valueForKey:@"isNetWorkAvailable"];
             if ([networkCheck isEqualToString:@"NotConnected"])
             {
                 // not connected
                 dispatch_async(dispatch_get_main_queue(), ^{
                     // Display/dismiss your alert
                     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No network connection" message:@"You must be connected to the internet to proceed." delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil];
                     [alert show];
                 });

             } else
             {
                 fNameStr = [[NSString alloc] init];
                 lNameStr = [[NSString alloc] init];
                 emailStr = [[NSString alloc] init];

                 [self startProgressViewAgain];
             }

         }
     }];
}
else
{
    //show tweeet login prompt to user to login
    TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];

    //hide the tweet screen
    viewController.view.hidden = YES;

    //fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
    viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
        if (result == TWTweetComposeViewControllerResultCancelled) {
            [self dismissModalViewControllerAnimated:NO];
        }
    };
    [self presentModalViewController:viewController animated:NO];

    //hide the keyboard
    [viewController.view endEditing:YES];
}
Run Code Online (Sandbox Code Playgroud)