IOS5 - manual review of storyboards in code

I am new to iOS and using storyboards for the first time. When my application starts, it checks using the server application that I wrote to check if the saved credentials have passed, and then in my AppDelegate class I will try to show the corresponding scene in the application storyboard - MainMenu, if it is complete, or the login screen into the system if not authenticated.

I tried using instantiateViewControllerWithIdentifier on the storyboard, as well as performSegueWithIdentifier on the initial navigation controller, which is set to "Initial View Controller" to display the corresponding view.

However, with both methods, only an empty navigation bar is displayed, and I'm not sure where to go from here.

If there was some example code about how others manually manipulate storyboard scripts and viewcontrollers, that would be great. Perhaps I put the code in the wrong place (i.e. Should it go into the first view controller), or does it not matter? There are no exceptions, and I seem to have access to instantiated objects as needed.

I think I need to better understand the operation of the application delegation window, or maybe I should focus on manually loading the storyboard by deleting its link from the InfoPlist settings?

Any thoughts would be greatly appreciated.

+4
source share
1 answer

From my (admittedly, erratic) understanding of the storyboard (for now), you should have two segues names coming from the first view controller, and then you can just run one or the other as needed (I assume there is some kind of loading / authentication screen, however short?)

if (success) { [self performSegueWithIdentifier: @"MainMenuSegue" sender: self]; } else { [self performSegueWithIdentifier: @"LoginSegue" sender: self]; } 

To debug, I would set buttons on the initial view manager to make sure that the segue / etc bindings are correct.

You really don't need to instantiate ViewControllerWithIdentifier unless you work with segue / storyboard restrictions. I think.

I put a performSegueWithIdentifier in my first viewcontroller of the viewDidAppear application (I don’t think this is the best idea, but most likely it will happen earlier, and I would like to hedge by saying that it should start somewhere on the viewcontroller stack, not from appdelegate. but I have not tested this).

+2
source

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


All Articles