我有一个登录名和家庭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 ....")
}
}
}
答案 0 :(得分:1)
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)
}