Problem
Pocketed in the development process input,I have always been plagued by a problem,That is when the user clicks on the left edge of the screen, UIButton target touchDown event almost turned into a touchUpInside 。That is,Both occur simultaneously,And when you press only when, touchDown no longer be called until the moment you lift your finger,Only trigger touchDown 。 It is quite clear on the keyboard,Touch-tone、Key visual cues and vibrating alert are therefore postponed,When continuous input,In the event of the left edge of the screen Q Key,It is obvious to feel what type flow Caton。 In fact, this problem is due to the 3D Touch multitasking and swipe gesture to switch back from the edge of the screen to the right leads to the。Because the two are global system iOS,So it is difficult to bypass the upstream bug。Even in the iPhone X Series in full screen,Keyboard This problem has not improved,Have become the situation on both sides of the screen are delayed。
App in solution
This error is a long time,But until iOS 11,With barely be considered a solution: preferredScreenEdgesDeferringSystemGestures: UIRectEdgeYou need to override this variable in your ViewController,Let your app a higher priority than a gesture to the system。
1 2 3 |
override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge { return [.top,.left,.right,.bottom] } |
In keyboard configuration program
Measures proposed above,In the extended keyboard is not in force - becauseAnd do not have permission。to this end,I made a subclass of UIButton,And where func point(inside point: CGPoint, with event: UIEvent?) -> Bool This method is used to determine the user clicks,Its advantage is that no matter where the user clicks,The first time will be triggered。
1 2 3 |
if super.point(inside: point, with: event), event?.type == UIEvent.EventType.touches { sendActions(for: UIControl.Event.touchDown) } |
Original article written by LogStudio:R0uter's Blog » Pocketed X input method is how to deal with the problem of delayed edge of the screen
Reproduced Please keep the source and description link:https://www.logcg.com/archives/3094.html
Hello,This part of the code is to provide UIButton subclass of it?
Unfortunately this part of the code I've gone,Because I finally changed another way to achieve the effect ...... Click on this program because my key processing flow for ...... some conflict areas。