检查推特是否已连接iOS 5

时间:2012-04-13 04:53:15

标签: iphone objective-c ios twitter

我如何检查我是否可以在Twitter上为iOS5制作TWRequest,因为我没有访问令牌?使用常规的twitter REST API,使用MGTwitterEngine等框架,我们可以检查访问令牌。

2 个答案:

答案 0 :(得分:0)

试试这个:)

-(IBAction)updateTwitter:(id)sender {

    [tweetTextField resignFirstResponder];

    if(![_engine isAuthorized]){ 
        UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];
        if (controller) {
            [self presentModalViewController:controller  animated:YES];
        }
    }else
    {
        [_engine sendUpdate:tweetTextField.text];
    }
}

答案 1 :(得分:0)

你不需要它。在iOS5中,您只需要在iOS设置中输入用户名和密码。您只需要使用TWTweetComposeViewController并正确管理其回调块(completitionHandler)。在块中,您将收到有关操作的状态。

TWTweetComposeViewControllerResult Possible values for the result parameter of the completionHandler property.

enum TWTweetComposeViewControllerResult {
    TWTweetComposeViewControllerResultCancelled,
    TWTweetComposeViewControllerResultDone };
 typedef enum TWTweetComposeViewControllerResult TWTweetComposeViewControllerResult;


如果需要知道是否可以发送推文,只需使用类+ (BOOL)canSendTweet的类方法TWTweetComposeViewController
如果您需要更多控制权,可以使用TWRequest代替TWTweetComposeViewController
点击此处:https://developer.apple.com/library/ios/#documentation/Twitter/Reference/TwitterFrameworkReference/_index.html

相关问题