我目前正在将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>
.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];
}
关于可能导致这种情况的任何想法?
答案 0 :(得分:0)
在我看来,应该从AppDelegate.m中删除行[FBSDKLoginButton class];
,因为您要在故事板中添加该类。尝试删除它,看看是否仍然发生崩溃。
在Facebook Login for iOS中,它代表那条代码:
这会在视图显示之前加载FBSDKLoginButton。
我不相信当已经通过Interface Builder添加FBSDKLoginButton类时,这是必要的。