0

アプリでFBConnectを使用しています。ログインアクションシートのボタンのタイトルは「Facebookにログイン」と「Facebookからログアウト」ですが、「Facebookにログイン」と「Facebookに公開」を表示したいのですが。現在、このように見えます...

代替テキストhttp://freezpic.com/pics/6944f45f17ba4bbb8220637d5a00a1c6.jpg

...でもこんな感じにしたい...

代替テキストhttp://www.freezpic.com/pics/93f28f4f9103f0842c849d7daa644f81.jpg

...おそらくこれらのメソッドで設定されます:

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

    //Show button log out

}

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

    //show button log in
}

Edit01-回答コメントからのアラートシートコード:

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

2 に答える 2

2

もちろん、Facebook接続の状態に応じて、これら2つのボタンだけで異なるUIActionSheetを表示するだけです。

どうですか:

-(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]; 
}
于 2010-02-02T12:26:51.963 に答える
0

最後に私はそれを実装します! (alreadyLoggedInToFacebook)でなければなりません(season.isConnect)。すべてが良いです !しかし、まだ問題があります。ログイン後-ログアウトして共有するとうまくいきましたが、うまくいきませんでした! これは、ユーザーがログアウト ボタンをタップすると、ログイン ウィンドウが再び表示されることを意味します。なぜ ?FBLoginButtonこのメソッドを削除すると、UIActionSheetが表示されないためだと思います

! ここに私のコードがあります:

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

}
于 2010-02-04T19:42:51.407 に答える