0

I have TabBarViewController and with tap on several of tabBarItems I must to check, if authorize user. If user is not authorised (it's a simple function returns true/false), I must present him viewController with authorisation, but if he is authorised, viewController will not must present. Questions: 1) If I do it in class UITabBarController of my TabBarController in func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {}, then first was loaded view of tabBarItem, and then I get my authorisation vc. How could I do it and where? screen of my code

2) How can I present from my authorisation vc (it has not tabbar) my view of tabBarItem? If I do it simply with self.present(animated: true, completion: nil), then with presenting I lose bottom tabBar. what I need screen and what I have screen

Eric Aya
  • 69,473
  • 35
  • 181
  • 253

1 Answers1

0

you can use

func setViewControllers(_ viewControllers: [UIViewController]?, 
           animated: Bool)

inside function check if user has been authorized then put your view controllers if not put array of viewController with authorisation

Mkhakpaki
  • 120
  • 2
  • 12
  • Add your viewcontrollers to tabbar programmatically and instead of checking for authorized person at selecting tabs check for authorized person only once and when you are adding your viewcontrollers to tabbar? Is it still not clear? – Mkhakpaki Dec 09 '17 at 16:49