0

Twitterをアプリケーションに統合しています。Twitterページを開くことに成功しましたが、SA_OAuthTwitterEngineデリゲートメソッドが呼び出されていません。以下は私のコードです。

Twitterボタンをクリック

-(void)twitterLogin
{
    [self twitterLogout];
    if(!_engine)
    {
        _engine=[[[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self]autorelease];
        _engine.consumerKey=NSLocalizedString(@"consumerKey", nil);
        _engine.consumerSecret=NSLocalizedString(@"consumerSecret", nil);
    }

    UIViewController *controller=[SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];
    if (controller)
    {
        [self presentModalViewController:controller animated:YES];
    }
 }

-(void)twitterLogout
{    
    NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (NSHTTPCookie* cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
        [cookies deleteCookie:cookie];
    }
    [_engine clearAccessToken];
    [_engine release];
    _engine=nil;
}

このメソッドは完全に機能しますが、以下のメソッドは呼び出されません

- (void) storeCachedTwitterOAuthData: (NSString *) data forUsername: (NSString *) username 
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    [defaults setObject: data forKey: @"authData"];
    [defaults synchronize];
    NSLog(@"%@",username);

}

前もって感謝します。

4

1 に答える 1

-1

このようなことをする

`if(!_engine){  
        _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];  
        _engine.consumerKey    = kOAuthConsumerKey;  
        _engine.consumerSecret = kOAuthConsumerSecret;  
    }   
    if(![_engine isAuthorized]){  
        UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];  

    if (controller){  
        [parent presentModalViewController: controller animated: YES];


        //hasTWLoggedInBefore=YES;
    }  
}  else{

    NSLog(@"IT IS ALRADY LOGIN");
    // Inform the delegate that Login is successful
    if ( [delegate respondsToSelector:@selector(TWloginStatus:)] ) 
    {
        // calling delegate method. For this method to function, the delegate should be implemented in the calling class.
        [delegate TWloginStatus:YES];               
        return;
    }       }` to load the twitter.
于 2012-06-21T13:48:46.430 に答える