嗨在這裏工作,我得到第四VC
類視圖控制器的實例:的UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonTapped(sender: AnyObject) {
print("ViewController - buttonTapped()")
performSegue(withIdentifier: "seg4", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "seg1" {
let tabVC = segue.destination as! UITabBarController
let navVC = tabVC.viewControllers![0] as! UINavigationController
let destVC = navVC.viewControllers[0] as! Seq1 // ==> this transition is working
print(destVC)
}
else if segue.identifier == "seg4"{
let tabVC = segue.destination as! UITabBarController
let navVC = tabVC.viewControllers![3] as! UINavigationController
let destVC = navVC.viewControllers[0] as! Seq4 // ==> this transition is working
destVC.hello()
print(destVC)
}
}
}
類SEQ1:UIViewController的{
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
類SEQ2:UIViewController的{
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
} 類SEQ3:的UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
} 類SEQ4:UIViewController的{
override func viewDidLoad() {
super.viewDidLoad()
print("Hello")
// Do any additional setup after loading the view, typically from a nib.
}
func hello() {
print("Hello")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
注:該標籤酒吧控制器將始終顯示FirstVC。因爲它是默認選擇。如果你想要,改變selectedIndex = 3
試試這樣navVC.topviewcontrolle as! FourthVC –