iOS中的FacebookSDK不显示关闭按钮并且无法关闭 [英] FacebookSDK in iOS Does not show close button and not able to close

查看:177
本文介绍了iOS中的FacebookSDK不显示关闭按钮并且无法关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为iOS 6应用集成了Facebook SDK.共享效果很好,但没有关闭FB Dialogue box.ie的措施.当"FB对话"框打开时,仅在身份验证成功后才会关闭.没有关闭或回退的准备.如何设置关闭按钮.我正在使用的代码段如下所示.感谢高级.

Hi I have integrated Facebook SDK for an iOS 6 app.The Facebook authentication & sharing works perfectly but there are no provision to close the FB Dialogue box.ie. When FB Dialogue box opens,it will be closed only after authentication success.No provision to close or navigate back.How can I make a close button.The code snippet I am using has been shown below.Thanks in Advance.

-(NSDictionary *)shareFacebook
{

    NSDictionary *userInfo;
    if (FBSession.activeSession.isOpen)
    {

        if (FBSession.activeSession.isOpen)
        {

            [self.closeButton setHidden:NO];
            [FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id<FBGraphUser> user, NSError *error) {

                NSUserDefaults *standardUserDefaults=[NSUserDefaults standardUserDefaults];
                [standardUserDefaults setObject:user forKey:@"fbUserInfo"];



                    [self.manager authenticateUserUsingFB:[user objectForKey:@"email"]];


            }];
        }

    }
    else{
        NSLog(@"fb session not active.");
        [self openSessionWithAllowLoginUI:YES];
    }
    return userInfo;
}

- (void)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {

    NSArray *permissions = [[NSArray alloc] initWithObjects:

                            @"user_photos",
                            @"publish_actions",
                            @"read_stream",
                            @"friends_photos",
                            @"email" ,nil];

    [FBSession setActiveSession:[[FBSession alloc] initWithPermissions:permissions]];


    [[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView

                              completionHandler:^(FBSession *session,

                                                  FBSessionState state,

                                                  NSError *error) {

                                  NSLog(@" state=%d",state);
                                  if(FBSessionStateOpen)
                                  {
                                      [self shareFacebook];
                                  }
                              }];

}

推荐答案

我知道导致此错误的原因!该按钮和图标视图(对话框右上角有两个视图-关闭按钮和图标视图)实际上存在(可以单击以查看),但不可见.这是因为项目看不到FBDialog.bundle中的实际图像文件.您应该从捆绑软件中复制这些图像,并将其添加到项目中,然后直接设置图像.您的init方法可能看起来像这样:

I know what causes this bug! The button and the icon view (there are two views on the top right corner of the dialog box - a close button and an icon view) are actually exist (you can click it to see) but not visible. This is because the project can't see actual image files which are located in FBDialog.bundle. You should copy those images from the bundle and add them to project then set images directly. Your init method may look something like this:

 //This is your FBDialog.m file
- (id)init {
  if (self = [super initWithFrame:CGRectZero]) {
    .........

    UIImage* iconImage = [UIImage imageNamed:@"fbicon.png"];
    UIImage* closeImage = [UIImage imageNamed:@"close.png"];

    _iconView = [[UIImageView alloc] initWithImage:iconImage];
    [self addSubview:_iconView];

    _closeButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
    [_closeButton setImage:closeImage forState:UIControlStateNormal];
    [_closeButton addTarget:self action:@selector(cancel)
      forControlEvents:UIControlEventTouchUpInside];

    .........

也许有更好的方法来修复此错误,但这对我有用.

May be there is a better way to fix this bug but this worked for me.

这篇关于iOS中的FacebookSDK不显示关闭按钮并且无法关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆