简体   繁体   English

ios Facebook登录按钮 - 不会更改为退出

[英]ios Facebook Login button - doesn't change to Log out

I'm using Xcode 6 & Facebook iOS SDK 4.3, I embedded the code, according to Facebook's guide and the login works, BUT from some reason - 我正在使用Xcode 6和Facebook iOS SDK 4.3,我嵌入了代码,根据Facebook的指南和登录工作,但由于某种原因 -

after I login, the button doesn't change to "Log out", and stays "Log in with Facebook". 登录后,该按钮不会更改为“注销”,并保持“使用Facebook登录”。

did anyone encounter this problem? 有没有人遇到过这个问题?

so I started all over, and followed the instructions from the guide : 所以我从头开始,按照指南中说明操作

1.in the viewController.h file: 1.在viewController.h文件中:

#import < FBSDKCoreKit/FBSDKCoreKit.h> //<-delete the space

#import < FBSDKLoginKit/FBSDKLoginKit.h>//<-delete the space

@interface ViewController : UIViewController<FBSDKLoginButtonDelegate>
@property (weak, nonatomic) IBOutlet FBSDKLoginButton *loginButton;

2.in the viewController.m file: 2.在viewController.m文件中:

-(void) viewDidLoad{
   if ([FBSDKAccessToken currentAccessToken]) {
   // User is logged in, do work such as go to next view controller. 
   }

   self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];

   FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
  [self.view addSubview:loginButton];
}

and after that didn't work, I've found this thread that mentioned I also need to add few things to the AppDelegate didFinishLaunchingWithOptions : 之后没有用, 我发现这个提到的线程我还需要为AppDelegate添加一些东西didFinishLaunchingWithOptions

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

and

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

and then it worked! 然后它工作了! finally I had the Log in button changed to Log out ! 最后我将登录按钮更改为退出

I was experiencing the same issue, and couldn't find the answer anywhere. 我遇到了同样的问题,无法在任何地方找到答案。 Turns out it was a Simulator problem; 原来这是一个模拟器问题; once I ran the same code on the device (iOS 9.3.1) everything worked out fine. 一旦我在设备上运行相同的代码(iOS 9.3.1),一切都很顺利。

请记住启用钥匙串共享功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM