Syed e Hussaini Syed e Hussaini - 1 year ago 92
Objective-C Question

UITabBarController is running parallel with my splashsceen

I have a

container 4 view controllers and two other view controllers as
as i have set
as root view controller and initiate splash screen with the help of navigation controller in my storyboard but when i actually run the app tabBarController and splash screen both run simultaneously. I want to load all of the views of the tab bar to be load after the splash screen and submission of login details.
Here is my code where i set root view controller.

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

HomeViewController *homeVC = [[HomeViewController alloc]init];
homeVC.title = @"Home";

NotificationViewController *notificationVC = [[NotificationViewController alloc]init];
notificationVC.title = @"Notifications";

ProfileViewController *profileVC = [[ProfileViewController alloc]init];
profileVC.title = @"Profile";

SelfiesCollectionViewController *selfiesCollectionVC = [[SelfiesCollectionViewController alloc]init];
selfiesCollectionVC.title = @"Selfie Collection";

homeVC = [storyBoard instantiateViewControllerWithIdentifier:@"HomeViewController"];

profileVC = [storyBoard instantiateViewControllerWithIdentifier:@"ProfileViewController"];

notificationVC = [storyBoard instantiateViewControllerWithIdentifier:@"NotificationViewController"];

selfiesCollectionVC = [storyBoard instantiateViewControllerWithIdentifier:@"SelfiesCollectionViewController"];

self.tabBarController = [[UITabBarController alloc]init];
self.tabBarController = [storyBoard instantiateViewControllerWithIdentifier:@"UITabBarController"];
self.tabBarController.viewControllers = @[homeVC,notificationVC,profileVC,selfiesCollectionVC];

UINavigationController *navigationVC = [[UINavigationController alloc]init];
navigationVC = [storyBoard instantiateViewControllerWithIdentifier:@"UINavigationController"];

[self.window setRootViewController:navigationVC];

Answer Source

You should not alloc and init your tabBarController before or the need. In your you need to make a public method like below. Remove the allocation and initiation of tabBarController from application launchWithOption method

     self.tabBarController = [[UITabBarController alloc]init];
self.tabBarController = [storyBoard instantiateViewControllerWithIdentifier:@"UITabBarController"];
self.tabBarController.viewControllers = @[homeVC,notificationVC,profileVC,selfiesCollectionVC];
[self.window setRootViewController:self.tabBarController];


Now simply call this method on the success of login button like this..

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate userDidLoggedIn];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download