开发者

Is it possible to implement iphone FBConnect without FBLoginButton?

i use UIActionSheet to share something to faceook . every thing is good ! but still a problem . after user login on facebook -/////// logout and share buttons show bgreat but didn't work great ! it means if user tap Logout button , login window appears again ! why ? i think , its because of FBLoginButton , when remove this method my UIActionSheet doesn't Show . does it way to implement FBConnect without FBLoginButton ? here is my codes :

-(IBAction)mySheet:(id)sender
{
    if (session.开发者_开发百科isConnected) {
        UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"FaceBook"
                         delegate:self  cancelButtonTitle:@"Cancel"
                         destructiveButtonTitle:nil
                         otherButtonTitles: @"Share On the Facebook" , @"Log out Facebook" ,nil]; 
        [menu showInView:self.view]; 
        [menu release]; 
     } else {
        UIActionSheet *menu2 = [[UIActionSheet alloc] initWithTitle:@"FaceBook"
                         delegate:self  cancelButtonTitle:@"Cancel"
                         destructiveButtonTitle:nil
                         otherButtonTitles:  @"Log in Facebook" ,nil]; 

        [menu2 showInView:self.view]; 
        [menu2 release]; 
    }
}

- (void)actionSheet:(UIActionSheet *)menu2 didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex != [menu2 cancelButtonIndex]) 
    {    
        FBLoginDialog* login = [[FBLoginDialog alloc] initWithSession:session];
        [login show];
        [login release];
    } 
}

- (void)actionSheet:(UIActionSheet *)menu didDismissWithButtonIndex2:(NSInteger)buttonIndex {
    if (buttonIndex != [menu cancelButtonIndex]) 
    {
        [session logout];
    }   
}


If you jump to the definition of FBLogin you see it implements the FBSessionDelegate. Your goal as I see it would be to populate the session object. So if you implement that delegate and properly populate the session you should be good to go. Then you can use logout/willLogout/sessionDidLogout on the session explicitly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜