私は自分のSDKからFacebookのログインボタンを持っていて、テキストを変更したいと思います。私はこのコードを試しました:SwiftでFacebookボタンのテキストをプログラムで変更するにはどうすればいいですか?
facebookButton.setTitle("my text here", forState: .Normal)
しかし、動作しません。それを行う方法はありますか?
これは、Facebookのログインボタンのコードは次のようになります。
//MARK: Facebook Login
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil {
facebookAPILogin(FBSDKAccessToken.currentAccessToken().tokenString, completionHandler: { error in
if error == nil {
self.performSegueWithIdentifier("loginToHomeSegue", sender: self)
} else {
self.showAlertWithTitle("Sorry".localized(), message: "There was a problem connecting with Facebook".localized())
print(error)
}
}
)
} else {
showAlertWithTitle("Sorry".localized(), message: "There was a problem connecting with Facebook".localized())
print(error.localizedDescription)
}
}
//Facebook Logout
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
print("User logged out")
}
私は現時点でObjective-Cを使用していますが、そのコンセプトにはスポットがあります。私はFBSDKLoginButtonとFBSDKButtonのソースを見てきました。 FBSDKLoginButtonはわずかなプロパティを追加し、FBSDKButtonを拡張します。 FBSDKButtonは新しいプロパティや関数を追加せず、UIButtonを拡張します。したがって、FIBDKLoginButtonにはUIButtonのすべての概念が存在します。これは私には明らかだったはずですが、時には最も単純な概念を実現するために示す必要があります。ありがとう! – Armand
はtvosで動作しません – reggie