我正在使用Xcode 6& Facebook iOS SDK 4.3, 我根据Facebook's guide嵌入了代码,登录工作,但是 出于某种原因 -
登录后,该按钮不会更改为“退出”,并保持“使用Facebook登录”。
有没有人遇到过这个问题?答案 0 :(得分:6)
so I started all over, and followed the instructions from the guide:
1.in the viewController.h file:
#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:
-(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 :
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!
答案 1 :(得分:2)
我遇到了同样的问题,无法在任何地方找到答案。 原来这是一个模拟器问题;一旦我在设备上运行相同的代码(iOS 9.3.1),一切都很顺利。
答案 2 :(得分:0)
请记住启用钥匙串共享功能