iphone - 是否可以检查用户在iOS 5的内置Twitter应用程序中是否具有Twitter帐户?

标签 iphone ios ipad twitter

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

iOS 5 SDK中开发人员的新功能之一是支持
Twitter API。苹果使开发人员轻松添加Twitter
支持其应用程序,并允许用户轻松控制是否或
没有应用有权访问其Twitter帐户。

根据this site,这是可能的。 Twitter框架的名称如何?

最佳答案

试试这个:

- (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
    }
}

关于iphone - 是否可以检查用户在iOS 5的内置Twitter应用程序中是否具有Twitter帐户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8248068/

相关文章:

ios - 使用 UIPicker 在 UITableViewController 中创建所需的行数

iphone - 自动 checkin / checkout

ios - 保存和读取图像阵列

iphone - 使用大量 CALayer 对象时优化性能的技巧?

iphone - 花栗鼠物理学 : how to predict the path of a body including bounces

ios - 根据屏幕大小快速更改按钮高度

ios - NSString 的值是 iOS 中的 NSInteger 值吗

ios - 无法使用 AVCaptureAudioDataOutputSampleDelegate 播放从语音录制的音频

objective-c - 另一个 EXC_BAD_ACCESS

iphone - 交换 SQLite 数据库中项目的顺序