JMGECH
JMGECH

Reputation: 653

Storyboard with conditional ViewControllers

I'm new working with Storyboards, so I'd appreciate any help!

I have a Settings view controller which should only appear if no previous settings exist. If those have been set, a different vc (the main one) is loaded.

I tried using the method in the attached image, but I'm not sure that's correct...

In the RootViewController I'm testing in viewDidLoad if settings were previously set or not, and am triggering the Segue with either ShowMain or ShowSettings as identifiers.

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

Of course RootViewController shows up in the NavigationController hierarchy (with the back button showing), which I don't want.

How should I be going about this?

Tia! S.enter image description here

Upvotes: 0

Views: 528

Answers (1)

Phillip Mills
Phillip Mills

Reputation: 31016

If, as it seems, the RootViewController only exists to decide which real controller to show, I'd suggest you get rid of it. Your main controller can be set as the first controller and have the settings logic in its viewDidLoad. Then, make your settings controller be presented using a modal segue. Once you're finished with the settings (if necessary), dismiss it and you're back to the main one.

Upvotes: 2

Related Questions