嗨在这里工作,我得到第四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 –