Resolved: Swift iOS sometimes not detecting touches


I am creating an iOS keyboard extension with UIInputViewController, and using UIButton for each key. I have two issues:
  1. Sometimes buttons don’t detect touches.
  2. Touches at the edges of the screen are recognized with a delay.

I assume first one happens when I type too fast, or when touch area is too big (bigger than the button). I tried using different methods of detecting touch (button target, touchesBegan, touchesEnded, UITapGestureRecognizer) and all have the same issue.
I assume second happens because of the iOS edge false touch rejection. I tried changing preferredScreenEdgesDeferringSystemGestures but it had no effect.
Please help.


  1. Turns out I was playing a quick animation on the UIButton press, so I had to set .allowUserInteraction in the animation options.
  2. I used UILongPressGestureRecognizer with minimumPressDuration = 0 which, for some reason, is always instant even at the edges.

If you have better answer, please add a comment about this, thank you!