[FBSDKLoginButton analyticsParameters]:发送到实例的无法识别的选择器

时间:2015-04-22 02:47:51

标签: ios objective-c facebook facebook-login facebook-ios-sdk

我目前正在将FB SDK从3.x升级到4.0.1。我只对我的应用程序使用FB登录,对于此功能,我使用FBSDKLoginButton。我正确地遵循了每个升级步骤并设法让它运行几次,但之后它一直崩溃并返回这些错误:

[FBSDKLoginButton analyticsParameters]: unrecognized selector sent to instance 0x7feb70e89af0

我的实施

在我的AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    // I create my button using storyboard.
    [FBSDKLoginButton class];

    ...

    return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}

在我的ViewController.h

@interface SLLandingController : UIViewController <FBSDKLoginButtonDelegate>

@property (weak, nonatomic) IBOutlet FBSDKLoginButton *FBLoginButton;

@end

在我的ViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self customizeViews];
    ...
    self.FBLoginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
    self.FBLoginButton.delegate = self;
}

我还实现了以下所有先决条件:

  • 链接FBSDKCoreKit和&amp; FBSDKLoginKit正确。{/ li>
  • 使用FB App ID设置.plist个文件&amp;显示名称。
  • 实施loginButton:didCompleteWithResult:error委托方法

使用断点跟踪到CoreKit > FBSDKButton.m

- (void)layoutSubviews
{
  // automatic impression tracking if the button conforms to FBSDKButtonImpressionTracking
  if ([self conformsToProtocol:@protocol(FBSDKButtonImpressionTracking)]) {
    ...
    // It breaks here
    NSDictionary *parameters = [(id<FBSDKButtonImpressionTracking>)self analyticsParameters];
    ...
  }
  [super layoutSubviews];
}

关于可能导致这种情况的任何想法?

1 个答案:

答案 0 :(得分:0)

在我看来,应该从AppDelegate.m中删除行[FBSDKLoginButton class];,因为您要在故事板中添加该类。尝试删除它,看看是否仍然发生崩溃。

Facebook Login for iOS中,它代表那条代码:

  

这会在视图显示之前加载FBSDKLoginButton。

我不相信当已经通过Interface Builder添加FBSDKLoginButton类时,这是必要的。