我想實現從視圖控制器的按鈕賽格瑞/故事板在迅速3故事板或SEGUE從視圖控制器到的TabBar控制器
標籤欄控制器(首頁)這是我的代碼標誌
@IBAction func LogIn(_ sender: Any) {
if self.emailTextfield.text == "" || self.passwordTextfield.text == "" {
let alertController = UIAlertController(title: "Error", message: "Please enter an email and password.", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
} else {
FIRAuth.auth()?.signIn(withEmail: self.emailTextfield.text!, password: self.passwordTextfield.text!) { (user, error) in
if error == nil {
print("You have successfully logged in")
//this is my storyboard but it gives me black screen
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
self.present(vc!, animated: true, completion: nil)
} else {
let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
}
}
我試着用故事板
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
self.present(vc!, animated: true, completion: nil)
我嘗試使用賽格
self.performSegue(withIdentifier: "Home", sender: self)
都給我黑屏。爲什麼?我也有一個澄清。我應該在哪裏連接我的segue,是在標籤欄控制器(灰色)還是第一個TAB控制器?
ü需要創建的TabBar類從ViewController導航到TabBarcontroller –
我已經創建了一個HomeViewController.swift。只是爲了縮短我的問題:如何從視圖控制器中繼續(如果使用segue)或故事板(如果使用故事板)從視圖控制器到TAB欄控制器?我知道如何從視圖控制器繼續到另一個,但在標籤欄我不知道。 – Lonewulf
我認爲你已經創建了新的類下的Tabbar,鏈接 - https://drive.google.com/file/d/0B1bdnxm63q27cE02dzNod2Yyd3M/view?usp=sharing –