Donavon Yelton
Donavon Yelton

Reputation: 1237

Disable a single storyboard?

Is there a simple way to disable a single storyboard scene based on a condition?

I'm using to check if location services are enabled for my app:

[CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied

If the above is true then I want to disable a scene that I created and the associated segues to get to that scene (I'm using left/right swipe gestures).

** UPDATED: I was confusing multiple storyboards with multiple scenes...my question has been updated to reflect this. I'm wanting to disable a specific scene in my storyboard, not a storyboard.

Upvotes: 0

Views: 110

Answers (2)

Donavon Yelton
Donavon Yelton

Reputation: 1237

I ended up taking a hint from this post: https://stackoverflow.com/questions/8309104/enable-disable-swiper-gesture-or-view-change-in-storyboard

I just created an IBOutlet in the header for a swipe gesture and placed the following code in an if statement that checks if the user has location services enabled or not and wired it up in addition to the segue in IB:

swipe.enable = NO;

Thanks for the assistance all!

Upvotes: 0

Caleb
Caleb

Reputation: 125007

To do what you want, you should write an action in your view controller that uses the condition(s) you set to choose the scene to segue to (or none at all). Don't just have a button or gesture trigger a push segue -- have it trigger the action in the view controller so that you can select the next scene in your code.

It's all well and good that you can set up segues right in the storyboard file, and it makes a great demo, but when you want to determine the destination scene at runtime you need to do that in code.

Upvotes: 1

Related Questions