使按钮touchUpInside FBLoginView [英] Make Button touchUpInside FBLoginView
本文介绍了使按钮touchUpInside FBLoginView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个具有属性loginButton的FBLoginView,并且我想使不在同一视图中的按钮触发此FBLoginView内置按钮功能.有没有人有什么建议?谢谢
I have a FBLoginView with property loginButton, and I want to make a button that is not in the same view fire this FBLoginView built in button feature. Does anyone have any suggestions? thanks
推荐答案
下载最新的facebook SDK安装程序并导入coreKit&目标中的LoginKit框架.
Download latest facebook SDK install and import coreKit & LoginKit frameworks in target.
创建一个示例按钮并执行操作.
Create one sample button and give action.
例如:
[fbLogin addTarget:self操作:@selector(facebookLogin :) forControlEvents:UIControlEventTouchUpInside];
Ex:
[fbLogin addTarget:self action:@selector(facebookLogin:) forControlEvents:UIControlEventTouchUpInside];
#import<FBSDKCoreKit/FBSDKCoreKit.h>
#import<FBSDKLoginKit/FBSDKLoginKit.h>
-(void)facebookLogin:(id)sender
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
NSLog(@"error %@",error);
} else if (result.isCancelled) {
// Handle cancellations
NSLog(@"Cancelled");
} else {
if ([result.grantedPermissions containsObject:@"email"]) {
// Do work
[self fetchUserInfo];
}
}
}];
}
-(void)fetchUserInfo
{
if ([FBSDKAccessToken currentAccessToken]) {
NSLog(@"Token is available");
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"Fetched User Information:%@", result);
}
else
{
NSLog(@"Error %@",error);
}
}];
} else {
NSLog(@"User is not Logged in");
}
}
这篇关于使按钮touchUpInside FBLoginView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文