简体   繁体   English

Facebook使用FBSDKLoginButton显示在情节提要和代码中添加的其他图片

[英]Facebook using FBSDKLoginButton showing different picture adding in storyboard and code

I am using FBSDKLoginButton in my app, everything working well, only difference I found out that when ever I try to add the button using the code, it adds up Facebook login button with text "Login with facebook" and when ever I try to put the button through the storyboard it shows "Login" only. 我在我的应用程序中使用FBSDKLoginButton ,一切正常,唯一的区别是我发现,当我尝试使用代码添加按钮时,它会添加带有文本“ Login with facebook”的Facebook登录按钮,而当我尝试放置时故事板上的按钮仅显示“登录”。

I want to to put the button through storyboard, can I change the style to one which I get through code. 我想通过情节提要放置按钮,我可以将样式更改为通过代码获得的样式吗?

        let loginView : FBSDKLoginButton = FBSDKLoginButton()
        self.view.addSubview(loginView)
        loginView.center = self.view.center
        loginView.readPermissions = ["public_profile", "email", "user_friends"]
        loginView.addTarget(self, action: "loginFb:", forControlEvents: UIControlEvents.TouchUpInside)

You just need to change the size. 您只需要更改大小即可。 If you increase the width enough it will update to the preferred style. 如果您增加足够的宽度,它将更新为首选样式。

First you define property to your .h file 首先,您要为.h文件定义属性

@property (strong, nonatomic) IBOutlet FBLoginView *loginView; @属性(强,非原子)IBOutlet FBLoginView * loginView;

and then take an UIButton in storyboard where you want to display and give class name as FBLoginView in inspector window set following property for UIButton 然后在要显示的情节提要中获取一个UIButton,并在检查器窗口中将类名称指定为FBLoginView,为UIButton设置以下属性 在此处输入图片说明

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

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