Search code examples
iosuitapgesturerecognizer

IOS: double tap gesture in an half of self.view


I want to recognizer an UITapGesture (add this gesture at self.view) only in left half in my self.view (landscape) what's the way to do it?


Solution

  • I think the easiest way to do this is to test for this in your gesture recognizer handling method. So when you detect the double tap have a conditional that tests to see if your origin point (which you can get from the reconigzer's locationInView method) has an X value that is less than half your view's width. If it does you know the tap is on the left hand side, and then you can proceed.