There is a task - to listen to all touch events and, with a certain number of such events, throw out the notification; how to implement this functionality?
Example listener method:

 var counter = 0 func listener(events: UIEvent) { if counter == 10 { NSNotificationCenter.post.... } counter++ } 
  • why only people do not come up with ... in general, all the cars? on all screens in any points? - Max Mikheyenko
  • @MaxMikheyenko For example, tachi for all UIControls - user204104
  • There is no time to write a complete answer, but the whole idea is this: you need as early as possible in the application (preferably in appDelegate) to replace - touchesBegan:withEvent: in UIResponder with your own method that will count tachi, and then call native touchesBegan: - Max Mikheyenko
  • @MaxMikheyenko thanks, but how can we remove only the buttons from all the tachets? - user204104
  • one
    try the same trick, but at the UIButton level (I'm not sure what happens, maybe UIButton does not override this method). Or if these are all your buttons, make your subclass, if these are not your buttons, then you can try to make a category on UIButton and redefine touchesBegan in it: (epl doesn’t recommend doing this, but you can try) - Max Mikheyenko

1 answer 1

the whole idea is this: you need as soon as possible in the application (preferably in appDelegate) to replace - touchesBegan:withEvent: in the UIResponder with your own method that will read tachi, and then call native touchesBegan:

if you need to do it only for UIButton: try the same focus, but at the UIButton level (I'm not sure what happens, maybe UIButton doesn't override this method). Or if these are all your buttons, make your subclass, if these are not your buttons, then you can try to make a category on UIButton and redefine touchesBegan in it: (epl doesn’t recommend doing this, but you can try)