iPhone:是否可以隐藏和取消隐藏 UIACtionSheet 按钮?

发布于 2024-08-20 11:28:24 字数 1427 浏览 0 评论 0原文

我在我的应用程序中使用 FBConnect。登录操作表按钮的标题是“登录 Facebook”和“注销 Facebook”,但我想显示“登录 Facebook”和“发布到 Facebook”。目前,它看起来像这样...

alt text 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]; 
}

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 http://freezpic.com/pics/6944f45f17ba4bbb8220637d5a00a1c6.jpg

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

alt text http://www.freezpic.com/pics/93f28f4f9103f0842c849d7daa644f81.jpg

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萝莉病 2024-08-27 11:28:24

当然,只需根据 Facebook 连接的状态显示仅包含这两个按钮的不同 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]; 
}

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]; 
}
记忆里有你的影子 2024-08-27 11:28:24

最后我实现了! (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];
    }

}

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

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文