Clancey / FlyoutNavigation

Other
95 stars 87 forks source link

Disabling flyout navigation programatically. #48

Closed jojojames closed 10 years ago

jojojames commented 10 years ago

Not sure how to disable the flyout navigation based on the API available.

There is a navigation.ShouldReceiveTouch but I'm not sure how to use it to disable the flyout from being used.

Thanks.

Clancey commented 10 years ago

You can just subscribe to the event and return false whenever you dont want swiping to work. Here is how I use it:

ShouldReceiveTouch = (sender, touch) => { bool isMovingCell = touch.View.ToString().IndexOf("UITableViewCellReorderControl", StringComparison.InvariantCultureIgnoreCase) > -1; if (isMovingCell || touch.View is UISlider || touch.View is MPVolumeView || isMovingCell || touch.View is ProgressView || touch.View is OBSlider) return false; return true; }

That makes it so it wont work on things like a UISlider.

jojojames commented 10 years ago

How would I use this from another controller?

(appDelegate.rootViewController as MainController).FlyoutNavigation.ShouldReceiveTouch = (sender, touch) => { return true; };

Thanks again.

Clancey commented 10 years ago

I would have a boolean on whatever class holds you menu. Optionally you could fork and just add a disable flag right on the menu itself.

jojojames commented 10 years ago

So there's a way to set whether not you can set the touch on a class that holds the FlyoutNavigation? I'm still getting a similar error, 'The event `FlyoutNavigation.FlyoutNavigationController.ShouldReceiveTouch' can only appear on the left side of + or -= when used outside of the type.'

From this error message, I'm thinking only your second recommendation would work unless I'm missing something.

Clancey commented 10 years ago

So yes its an event so you need FlyoutNavigation.ShouldReceiveTouch += (sender, touch) => { return true; };