我是新来的iOS和Objective-C,我想通过Facebook执行登录,所以我设法把FBSDKLoginButton,但我无法通过委托获得结果。我遵循官方指南,但仍然不适合我。 这是.h文件ios facebook登录按钮结果
//
#import <UIKit/UIKit.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
@interface LoginViewController : UIViewController <FBSDKLoginButtonDelegate>
@property (weak,nonatomic) IBOutlet FBSDKLoginButton *loginButton;
@end
,这是.m文件
//
#import "LoginViewController.h"
#import "CreatePartyViewController.h"
@interface LoginViewController()
@end
@implementation LoginViewController
@synthesize loginButton;
-(void)alredyLogged{
//[self performSegueWithIdentifier:@"loginS" sender:self];
}
-(void)viewDidAppear:(BOOL)animated{
if([FBSDKAccessToken currentAccessToken]){
[self alredyLogged];
NSLog(@"alredy_logged");
}
}
- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton{
NSLog(@"logout");
}
- (void)loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
error:(NSError *)error {
NSLog(@"Login");
}
- (void)viewDidLoad {
[super viewDidLoad];
loginButton.delegate = self;
loginButton.readPermissions = @[@"public_profile", @"user_friends"];
loginButton = [[FBSDKLoginButton alloc]init];
[FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
// Do any additional setup after loading the view.
}
@end
使用这种方法.. HTTP: //stackoverflow.com/questions/31528948/make-button-touchupinside-fbloginview/31562976#31562976 点击此链接。 – Ananth
对代码进行快速扫描,似乎是在初始化它之前设置属性。在一个不相关的笔记上,很高兴看到你如何将它添加到视图中。我建议查看https://developers.facebook.com/docs/facebook-login/ios#login-button,以防你没有 – corvuszero