6

In my app, I have UITabBarController, when user tapped on a tabbar item (e.g: tab index is 3), I want to check one condition (if...) to show different ViewController.

So my question is where to implement this condition function?

UdayM
  • 1,725
  • 16
  • 34
QuocTV
  • 199
  • 1
  • 8
  • if you want this type of condition so u can apply tab bar segue using programmatic – Jigar Apr 04 '16 at 05:49
  • Darji Jigar, I think so. Where can I add check method to show view controller when tapped TabBarItem? – QuocTV Apr 04 '16 at 07:03

2 Answers2

0

you need to set the delegate of the UITabBarController as below:

func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
    if viewController is TabBarDelegate {
        let v = viewController as! TabBarDelegate
        v.didSelectTab(self)
    }
}
iVarun
  • 6,496
  • 2
  • 26
  • 34
0

try with create tabbar by button and view is a scrollview

Sang Trần
  • 2,147
  • 4
  • 13
  • 20