是否可以检查用户是否在iOS 5的内置Twitter应用程序中拥有Twitter帐户? [英] Is it possible to check if a user has a twitter account in the built-in twitter app of iOS 5?

查看:69
本文介绍了是否可以检查用户是否在iOS 5的内置Twitter应用程序中拥有Twitter帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 5具有深度的Twitter集成。如何检查用户是否在内置的Twitter应用程序中有一个帐户(意味着他使用它),然后执行 UIApplication openURL:来触发关注用户或预编写推文?

iOS 5 has deep twitter integration. How can I check if the user has an account in the built-in twitter app (meaning he uses it), and then do a UIApplication openURL: to trigger following a user or pre-composing a tweet?


iOS 5 SDK中开发人员的一项新功能是支持
的Twitter API 。 Apple让开发人员可以轻松地为他们的应用添加Twitter
支持,并允许用户轻松控制是否或者b $ b而不是应用有权访问他们的Twitter帐户。

One of the new features for developers in the iOS 5 SDK is support for the Twitter API. Apple has made it easy for developers to add Twitter support to their apps and to allow users to easily control whether or not an app has access to post to their Twitter account.

根据这个网站是可能的。 Twitter框架如何调用?

According to this site it is possible. How's that Twitter Framework called?

推荐答案

试试这个:

- (void)tweetButtonPressed:(id)sender
{
     Class tweetComposer = NSClassFromString(@"TWTweetComposeViewController");

     if( tweetComposer != nil ) {   

         if( [TWTweetComposeViewController canSendTweet] ) {
            TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];

            [tweetViewController setInitialText:@"This is a test."];  // set your initial text

            tweetViewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
                if( result == TWTweetComposeViewControllerResultDone ) 
                {
                    // user is done with composing
                } 
                else if( result == TWTweetComposeViewControllerResultCancelled ) 
                {
                    // user has cancelled composing
                }
                [self dismissViewControllerAnimated:YES completion:nil];
            };

            [self presentViewController:tweetViewController animated:YES completion:nil];
        } 
        else {
             // The user has no account setup
        }
    }   
    else {
        // no Twitter integration
    }
}

这篇关于是否可以检查用户是否在iOS 5的内置Twitter应用程序中拥有Twitter帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆