我已经成功地将我的自定义 FB 登录实现到我的代码中,并且当我运行模拟器时它会显示/工作,但是,我想在其中实现我的自定义设计。有什么方法可以将它从我的代码中移出并将其显示为 Storyboard 上的按钮以添加所述自定义设计。
这是我已经编写的代码
导入UIKit 导入 Firebase 导入FBSDKLoginKit
类chooseLogInOrSignUpViewController:UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//add our custom FB log in here
let customFBButton = UIButton(type: .system)
customFBButton.backgroundColor = .blue
customFBButton.frame = CGRect(x: 16, y:50, width: view.frame.width - 32, height: 50)
customFBButton.setTitle("Connect with Facebook", for: .normal)
customFBButton.setTitleColor(.white, for: .normal)
view.addSubview(customFBButton)
customFBButton.addTarget(self, action: #selector(handleCustomFBLogin), for: .touchUpInside)
}
func handleCustomFBLogin() {
FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self)
{ (result,err) in
if err != nil {
print("Connect with Facebook failed", err)
return
}
print(result?.token.tokenString)
}
}
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "usersVC")
}
最佳答案
你不能。您无法在 Storyboard中查看自定义 View 。 Storyboard 仅渲染出 Apple 实现的某些 UIkit View 。
您可以使用自定义 View 来帮助定位您的 Facebook 登录信息,并使其成为 Facebook 登录信息的子类。但你什么也看不到
关于ios - 如何让 Facebook 的自定义登录显示在我的 Main.storyboard 上,而不仅仅是在我的代码中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43191196/