重定向到Twitter登录的设置屏幕 [英] Redirect to Settings Screen for Twitter Login
问题描述
在Twitter中,如果用户已在设置屏幕中的Twitter帐户中登录它将允许发布。否则它将显示警报为没有Twitter帐户,带有2个选项 设置和取消。如果点击取消
,它将关闭提醒并拒绝发布到Twitter。如果点击设置
,则不会重定向到设置屏幕。
我还用过
In Twitter ,if User has Logged In in the Twitter Account in Settings Screen It will allow to post.Or Else it will display a Alert as "No Twitter Accounts" with 2 Options "Settings" and "Cancel". If Cancel
is Tapped it will close alert and reject post to twitter. And if Settings
is Tapped it is not redirecting to Settings Screen.
Also i used
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]];
但是没有运气。据我检查,所有人都说从iOS 5.1它不会工作。但我看到一些应用程序仍然重定向到iOS7中的设置屏幕。是否可以在iOS7中重定向。
先谢谢。
But No Luck. As far as i checked all are saying as from iOS 5.1 it wont work.But i see some apps still redirecting to settings screen in iOS7. Is it possible to redirect in iOS7. Thanks in Advance.
推荐答案
您可以在登录按钮的操作中使用以下代码:
You can use below code in your login button's action:
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];
}
这篇关于重定向到Twitter登录的设置屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!