IOS When a tab element is used, I need to check the condition to show another view controller

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

So my question is where to implement this condition function?

+5
source share
2 answers

you need to set the UITabBarController delegate as shown below:

 func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) { if viewController is TabBarDelegate { let v = viewController as! TabBarDelegate v.didSelectTab(self) } } 
0
source

try creating a tab by button, and view is scrollview

0
source

Source: https://habr.com/ru/post/1246376/


All Articles