我成功定制了网络登录按钮,但我该怎么办呢?我一直在寻找,但却找不到任何东西。
我目前正在使用Facebook SDK 3.0并且它很容易实现,但FBLoginView按钮的设计像拇指一样伸出。我正在尝试使用动画按钮覆盖它,然后向后触摸真正的Facebook按钮。
Apple会在提交时拒绝这种解决方法吗? 必须有一个更简单的方法,不是吗?
答案 0 :(得分:1)
Possible Duplicate of "How to customize FBLoginVIew?" check both Question & Answer
根据我的知识,没有报告关于定制Facebook登录视图的拒绝问题
答案 1 :(得分:0)
是的,您可以使用以下代码进行更改。
for (id obj in loginview.subviews)
{
if ([obj isKindOfClass:[UIButton class]])
{
UIButton * loginButton = obj;
[loginButton setBackgroundColor:[UIColor blueColor]];
UIImage *loginImage = [UIImage imageNamed:@"facebook_btn~ipad.png"];
[loginButton setBackgroundImage:loginImage forState:UIControlStateNormal];
[loginButton setBackgroundImage:nil forState:UIControlStateSelected];
[loginButton setBackgroundImage:nil forState:UIControlStateHighlighted];
[loginButton sizeToFit];
}
if ([obj isKindOfClass:[UILabel class]])
{
UILabel * loginLabel = obj;
loginLabel.text = @"Login with facebook";
loginLabel.textAlignment = NSTextAlignmentCenter;
loginLabel.frame = CGRectMake(0, 30, 600, 30);
//loginLabel.text. = [UIFont fontWithName:@"Default" size:30.0];
[loginLabel setFont:[UIFont boldSystemFontOfSize:27]];
}
}
答案 2 :(得分:0)
请阅读Facebook SDK中的README文件。 你必须在info.plist中添加Row - FacebookBundleName并为它添加一个名称。 然后,使用此名称将捆绑包添加到项目中,并将其放入名为“lang.lproj”的文件夹中: 例如:en.lproj - it.lproj - fr.lproj - es.lproj .... 在这个文件夹中你必须添加Localizable.strings文件,然后你可以本地化很多短语,如:
"FBLV:LogOutButton" = "Log Out";
"FBLV:LogInButton" = "Log In";
"FBLV:LoggedInAs" = "Logged in as: %@";
"FBLV:LoggedInUsingFacebook" = "Logged in using Facebook";
"FBLV:LogOutAction" = "Log Out";
"FBLV:CancelAction" = "Cancel";
希望它可以帮到你!
答案 3 :(得分:0)
//Add the normal button then add your own image and tittle and give the action the button and use the below code in the button action.
NSMutableDictionary *fbResultData;
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile", @"email", @"user_friends"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
} else if (result.isCancelled) {
NSLog(@"Cancelled");
} else {
NSLog(@"Logged in");
if ([FBSDKAccessToken currentAccessToken])
{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=id,name,age_range,birthday,devices,email,gender,last_name,family,friends,location,picture" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSString * accessToken = [[FBSDKAccessToken currentAccessToken] tokenString];
NSLog(@"fetched user:%@ ,%@", result,accessToken);
fbResultData =[[NSMutableDictionary alloc]init];
if ([result objectForKey:@"email"]) {
[fbResultData setObject:[result objectForKey:@"email"] forKey:@"email"];
}
if ([result objectForKey:@"gender"]) {
[fbResultData setObject:[result objectForKey:@"gender"] forKey:@"gender"];
}
if ([result objectForKey:@"name"]) {
NSArray *arrName;
arrName=[[result objectForKey:@"name"] componentsSeparatedByString:@" "];
[fbResultData setObject:[arrName objectAtIndex:0] forKey:@"name"];
}
if ([result objectForKey:@"last_name"]) {
[fbResultData setObject:[result objectForKey:@"last_name"] forKey:@"last_name"];
}
if ([result objectForKey:@"id"]) {
[fbResultData setObject:[result objectForKey:@"id"] forKey:@"id"];
}
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:[NSString stringWithFormat:@"me/picture?type=large&redirect=false"]
parameters:nil
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
if (!error){
if ([[result objectForKey:@"data"] objectForKey:@"url"]) {
[fbResultData setObject:[[result objectForKey:@"data"] objectForKey:@"url"] forKey:@"picture"];
}
//You get all detail here in fbResultData
NSLog(@"Final data of FB login********%@",fbResultData);
self.fullNameTextField.text = [fbResultData objectForKey:@"name"];
self.lastNameTextField.text = [fbResultData objectForKey:@"last_name"];
[_customFaceBookButton setImage:[UIImage imageNamed:@"fb_connected"] forState:UIControlStateNormal];
} }];
}
else {
NSLog(@"result: %@",[error description]);
AlertView *alert = [[AlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:[error description] delegate:nil cancelButtonTitle:NSLocalizedString(@"DISMISS", nil) otherButtonTitle:nil];
[alert showInView:self.view.window];
}
}];
}
else{
[[FBSDKLoginManager new] logOut];
[_customFaceBookButton setImage:[UIImage imageNamed:@"fb_connected"] forState:UIControlStateNormal];
}
}
}];