我是iOS開發新手。我想用Firebase構建授權。我正在使用FirebaseUI-iOS。我想隱藏取消按鈕從初始屏幕。你有什麼想法如何做到這一點?FirebaseUI iOS刪除取消按鈕
創建火力地堡authViewController編程:
import UIKit
import Firebase
import FirebaseAuthUI
import FirebaseGoogleAuthUI
class AuthViewController: UIViewController {
fileprivate var _authHandle: FIRAuthStateDidChangeListenerHandle!
var user: FIRUser?
override func viewDidLoad() {
super.viewDidLoad()
configureAuth()
}
func configureAuth() {
let provider: [FUIAuthProvider] = [FUIGoogleAuth()]
FUIAuth.defaultAuthUI()?.providers = provider
FUIAuth.defaultAuthUI()?.isSignInWithEmailHidden = true
// listen for changes in the authorization state
_authHandle = FIRAuth.auth()?.addStateDidChangeListener { (auth: FIRAuth, user: FIRUser?) in
// check if there is a current user
if let activeUser = user {
// check if the current app user is the current FIRUser
if self.user != activeUser {
self.user = activeUser
let name = user!.email!.components(separatedBy: "@")[0]
print(name)
}
} else {
// user must sign in
self.loginSession()
}
}
}
func loginSession() {
let authViewController = FUIAuth.defaultAuthUI()!.authViewController()
present(authViewController, animated: true, completion: nil)
}
deinit {
FIRAuth.auth()?.removeStateDidChangeListener(_authHandle)
}
}
除了從下面給出的答案,我想你可以在故事板做到這一點。只需搜索navigationItemLeft或其他東西。 –
刪除指定一個左欄按鈕項目的代碼段,或者將其設置爲零。 –
@TylerRutt我以編程方式使用此取消按鈕創建視圖控制器。我使用FirebaseUI-iOS。在這種情況下,我不確定必須移除按鈕。我用代碼更新了我的問題。有任何想法嗎? –