1
votes

I have several buttons positioned on my ViewController within the area covered by the UIPageViewController's GestureRecognizers. Taps in this area are consumed by the UIPageViewController and never reach the buttons below.

I've read iPad - PageViewController - Show next view controller on button click and UIPageViewController Gesture recognizers and understand the principle but have no prior Obj-C experience and am struggling to recreate these solutions in C#.

Could somebody please provide an example of how this is done in MonoTouch?

1

1 Answers

2
votes

Here's how your first link would translate into C# using MonoTouch (note: untried).

First you would create your own (non .NET) delegate for UIGestureRecognizer like this:

class MyUIGestureRecognizerDelegate : UIGestureRecognizerDelegate {

    public override bool ShouldReceiveTouch (UIGestureRecognizer recognizer, UITouch touch)
    {
        return (!(touch.View is UIControl));
    }
}

It will return true to if the touch gesture does not apply to a UIControl (including buttons).

Then you need to assign this delegate to the GestureRecognizers that are assigned to your UIPageViewController.

MyUIGestureRecognizerDelegate del = new MyUIGestureRecognizerDelegate ();

UIPageViewController pvc = new UIPageViewController ();

foreach (var gr in pvc.GestureRecognizers)
    gr.Delegate = del;

This lets you adapt how the gesture will be interpreted. If not handled by the gesture itself then it should be routed to your own controls/buttons.