I want a particular tab to be opened at launch time in a tab bar application.I get the warningWarning: Attempt to present <settingsViewController: 0x16e49870> on <UITabBarController: 0x16d25440> whose view is not in the window hierarchy!
.
self.tabBarController.selectedIndex = 1;
I tried in DidFinishLaunching
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
numpadviewcontroller = [[tabBarController viewControllers] objectAtIndex:0];
settingsviewcontroller = [[tabBarController viewControllers] objectAtIndex:1];
[tabBarController setSelectedIndex:1];
But getting the same warning.I am using storyboards
I tried the code in viewWillAppear,ViewDidLoad also of the first controller of tab bar but i get the same error.
In both viewWillAppear and viewDidLoad the ViewController's view has not been loaded in the window hierarchy yet. I would try to add the code in viewDidAppear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With