gpt4 book ai didi

swift - 推送后不会出现导航栏

转载 作者:行者123 更新时间:2023-11-28 05:39:01 25 4
gpt4 key购买 nike

我有一个登录和主页 Viewcontrollers,从 loginVC 移动到 homeVC 后,导航栏被隐藏,我尝试了一些东西但没有任何效果。这就是我从登录到主页的方式:

func handleLogin() {
guard let email = self.mView.emailTxtField.text else { return }
guard let pass = self.mView.passTxtField.text else { return }
Service.shared.loginUser(email, pass) { (answer) in
if answer == true {

UserDefaults.standard.set(Auth.auth().currentUser?.uid, forKey: USER_UID_KEY)
let vc = HomeVC(collectionViewLayout: UICollectionViewFlowLayout())

let transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
transition.type = .push
transition.subtype = .fromTop
self.navigationController?.view.layer.add(transition, forKey: kCATransition)
self.navigationController?.pushViewController(vc, animated: false)

}else {
//TODO: SHOW ERROR
print("CAN'T LOGIN ....")
}
}
}

最佳答案

Login VC出现时必须隐藏导航栏,消失时隐藏。

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}

关于swift - 推送后不会出现导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57614796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com