views:

459

answers:

2

Hi. I am using FBConnect in my app. The log in action sheet buttons are title "Log in Facebook" and "LogOut Facebook" but I want to display "Log into Facebook" and "Publish to Facebook". Currently, it looks like this...

alt text

...but I want it to look like this...

alt text

... possibly set in these methods:

- (void)session:(FBSession*)session didLogin:(FBUID)uid {

    //Show button log out

}

- (void)sessionDidLogout:(FBSession*)session {

    //show button log in
}

Edit01- Alert sheet code from answer comment:

 -(IBAction)mySheet:(id)sender { 
    UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"FaceBook" 
                                                      delegate:self 
                                             cancelButtonTitle:@"Cancel" 
                                        destructiveButtonTitle:nil 
                                             otherButtonTitles:@"Share On the Facebook" , 
                                                                @"Log in Facebook" ,
                                                                @"LogOut Facebook" ,nil]; 
    [menu showInView:self.view]; 
    [menu release]; 
}
+1  A: 

Sure, just show a different UIActionSheet with just those two buttons depending on the state of the Facebook connection.

What about:

-(IBAction)mySheet:(id)sender
{
    if (alreadyLoggedInToFacebook) {
        UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"FaceBook"
            delegate:self  cancelButtonTitle:@"Cancel"
                destructiveButtonTitle:nil
                    otherButtonTitles: @"Share On the Facebook" ,  @"Log in Facebook" ,
                      @"LogOut Facebook" ,nil]; 
    } else {
        UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"FaceBook"
            delegate:self  cancelButtonTitle:@"Cancel"
                destructiveButtonTitle:nil
                    otherButtonTitles:  @"LogOut Facebook" ,nil]; 
    }
    [menu showInView:self.view]; 
    [menu release]; 
}
St3fan
sorry i don't exactly understand !can you show me with code? i implement UIActionSheet With this code ::-(IBAction)mySheet:(id)sender { UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"FaceBook" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Share On the Facebook" , @"Log in Facebook" ,@"LogOut Facebook" ,nil]; [menu showInView:self.view]; [menu release]; }
Momeks
Edit your question to include the code. I can't read that :-)
St3fan
The question had edited !:)
Momeks
thank you so much st3fan ! but ive got this error ! :http://freezpic.com/pics/be99dd92ea63f2eea321391bd15cd095.pngsorry iam new to iphone sdk
Momeks
A: 

Finally i implement that ! (alreadyLoggedInToFacebook) must be (season.isConnect) . every thing is good ! but still a problem . after login - logout and share show great but didn't work great ! it means if user tap Logout button , login window appears again ! why ? i think , its because of FBLoginButton , when delet this method my UIActionSheet doesn't Show

! here is my code :

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

}
Momeks