Evet - ama nasıl karmaşık olması gerekenden ne yaptığınızı bağlıdır.
Eğer sadece hiç o zaman basitçe viewWillAppear
veya viewWillLoad
işleve bazı kod ekleyebilirsiniz ilk UIViewController
dan giderseniz
Birden fazla giriş noktası varsa
override func viewWillAppear(animated: Bool)
{
self.selectedIndex = 2
}
(endeksini hatırlama sıfır tabanlı) tabBarController
'da bir bayrak ayarlamak için prepareForSegue
kullanabilirsiniz. Bu örnekte, iki 100 olarak ayarlanmış UIViewController
tag
ile değerlerine düğmeleri ve 200
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "TabBarSegue"
{
if let destinationVC = segue.destinationViewController as? myTabBarViewController
{
if sender!.tag == 100
{
destinationVC.jumpToTab2 = true
}
if sender!.tag == 200
{
destinationVC.jumpToTab2 = false
}
}
}
}
ve TabBarController
olarak, bir işaretle jumpToTab2
class myTabBarViewController: UITabBarController
{
var jumpToTab2 : Bool = false
override func viewWillAppear(animated: Bool)
{
if jumpToTab2
{
self.selectedIndex = 2
}
jumpToTab2 = false // reset the flag before next time
}
}
tanımlanmış olan