I am trying to navigate from one view controller to another using this code:
self.tabBarController?.selectedIndex = 1
self.tabBarController?.selectedViewController = self.tabBarController?.viewControllers![1]
When the code executes it goes to the desired UIViewController
but the view appears after a small delay and a black screen is visible during that time.
Found the answer just had to run the code in main thread
DispatchQueue.main.async {
self.tabBarController?.selectedIndex = 1
self.tabBarController?.selectedViewController = self.tabBarController?.viewControllers![1]
}
}