Why doesn't a Mac Catalyst app use numberOfTouchesRequired?

Viewed 408

I'm porting apps from iOS to Mac using Mac Catalyst and noticed that two- and three-finger tap gestures don't work. Here's some example code:

UIView *test = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
test.backgroundColor = [UIColor redColor];
[self.view addSubview:test];
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleColumns:)];
gesture.numberOfTouchesRequired = 2;
gesture.delegate = self;
[test addGestureRecognizer:gesture];

If I tap the red box with two fingers on my Magic Trackpad, nothing happens. The target method isn't called, nor are the gesture delegate methods like gestureRecognizer:shouldReceiveTouch:. However, if I comment out the numberOfTouchesRequired line, then a one-fingered tap works.

I don't see anything about this limitation in the documentation, and apparently it's not a general limit with multi-touch because a UIPinchGestureRecognizer works as expected. Am I missing something, or should I file a bug report?

1 Answers

Mac Catalyst seems to respond to a two finger click to show a UIContextMenuInteraction.

If you implement this, you can use this for showing a menu for a two finger click. Here is a decent tutorial.

Note: I am using mac catalyst in "Scale Interface to Match iPad" mode.

Related