I'm creating a custom keyboard extension. So as a result, there are buttons which are pinned to the left edge of the keyboard. (Think of q key as an example).
The logic of the key presses go something like this: Button detects a touchDown event and shows the magnified text which you normally see in system keyboard when tapping a key.
Button detects a touchUpInside/touchDragOutside event and the magnified text disappears, again very similar to the system keyboard.
This logic worked for all the buttons which were not pinned to the left edge of the keyboard. But for the buttons that were pinned to the left edge, the touchDown events were being detected after a second. So you can see this is obviously bad because I want to see the magnified text right after I place my finger on the button.
WHAT I TRIED AS AN ALTERNATIVE:
I removed all the touchDown, touchUpInside and touchDragOutside events from the button and disabled all their user interaction. Then I implemented to touches functions(touchesBegan, touchesEnded, etc.) and observed the touch locations on the background view. Surprisingly, even in this case, the touchesBegan function was called after a second after I placed my finger on the left edge of the screen and as usual, the touchesBegan function called just fine in the rest of the screen.
Here's the code for the touches function:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
		guard let touch = event?.allTouches?.first else { return }
		let location = touch.location(in: self.touchView)
				
		print(location)
}
What exactly is happening here? And what can I do to avoid this problem?
NOTE: It works fine in simulator for some reason but has a problem with real devices.
1
1
436