本文介绍了是否可以检查用户是否在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?

根据是可能的。 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帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 02:16