How to separate view controller from application loading using tabbarcontroller

I am using tabbarcontroller as the root view controller. Unfortunately, using the new storyboard functionality, it is difficult to display the view controller - login page - to download the application.

I am using the code below:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; [tabBarController performSegueWithIdentifier:@"loginPage" sender:self]; 

Setup is performed correctly. I entered one of the tab view controllers and did an IBAction, and it successfully passed. Thank you in advance.

+4
source share
2 answers

Go to the same question today. I had to call:

 [self.window makeKeyAndVisible]; 

before

 [self.window.rootViewController performSegueWithIdentifier:@"LoginView" sender:self]; 

So, I assume that when using storyboards, makeKeyAndVisible happens after didFinishLaunchinWithOptions: returns. Therefore, when they called segue, it happened on the screen, not on the screen.

+9
source

I recently turned to the same issue. However, the solution provided did not help me.

The reason was because I used a “push” segue to display my login controller (which is built into the navigation controller). Changing the segue style from "push" to "modal" did the trick for me. Apparently, it is not possible to initiate a “push” segue from within the tab bar controller, but only from the navigation controller.

In addition, I did not put the line

 [self performSegueWithIdentifier:@"LoginSegue sender:self]; 

in the didFinishLaunchingWithOptions:didFinishLaunchingWithOptions: delegate method, but rather in the viewDidAppear: method. For this, I do not need the following line of code:

 [self.window makeKeyAndVisible]; 

Hope this is helpful to others.

+1
source

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


All Articles