Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISystemGateGestureRecognizer and delayed taps near bottom of screen

What are the standard UISystemGestureGateGestureRecognizers installed on the top level UIView of an iOS app for?

My app consists of two views - one fills the top half of the screen, the other is a custom keyboard and fills the bottom half. I found that taps on the space bar didn't always work and after some investigation found that the timing of tap events in the bottom 20 pixels or so was different to the rest of the view. For most of the view the period between touchesBegan/Ended was about 100ms, where as for the space bar it was 1-2ms. (My app is an emulator and this is too fast for it to detect the key press).

After some more digging I found the main UIView of the application (ie: my main view's superview) has 2 UISystemGestureGateGestureRecognizer's installed. By removing them in ViewDidAppear the bottom of the screen is no longer affected. (Presumably these are cancelling the touch press events to my keyboard hence the faster timing).

These system recognizers are present on at least iOS 5 through 7 and on both iPad and iPhone. I thought they may be related to swipe from top/bottom but this functionality still works with them removed.

So I have a fix, but I'd like to understand more about what's going on here - in particular what I might be breaking by removing these.

like image 490
Brad Robinson Avatar asked Nov 05 '13 22:11

Brad Robinson


People also ask

What is gesture tap?

Tap and swipe are two common gestures that allow the user to perform primary actions on their mobile devices. The tap gesture is essentially a brief touch of the mobile screen surface with the fingertip. Common uses of this gesture in iOS and Android devices include: Select or submit. Activate.

How do I add tap gestures in Objective C?

Adding a Tap Gesture Recognizer in Interface Builder You don't need to switch between the code editor and Interface Builder. Open Main. storyboard and drag a tap gesture recognizer from the Object Library and drop it onto the view we added earlier. The tap gesture recognizer appears in the Document Outline on the left.

What is UITapGestureRecognizer Swift?

UITapGestureRecognizer is a concrete subclass of UIGestureRecognizer . For gesture recognition, the specified number of fingers must tap the view a specified number of times. Although taps are discrete gestures, they're discrete for each state of the gesture recognizer.


1 Answers

This delayed touches bothered me too. Just as an addition to what's said before, here's a simple fix:

override func viewDidAppear(_ animated: Bool) {
    let window = view.window!
    let gr0 = window.gestureRecognizers![0] as UIGestureRecognizer
    let gr1 = window.gestureRecognizers![1] as UIGestureRecognizer
    gr0.delaysTouchesBegan = false
    gr1.delaysTouchesBegan = false
}

no need to remove those gesture recognizers. just add this to the main view controller.

like image 69
heiko Avatar answered Sep 27 '22 19:09

heiko