3

I have noted recently that each of my app view has one particular bug/behaviour: if user taps too fast on a UI component when the view appears, the tap is simply ignored. If the user wait a bit before tapping, the tap works.

Storyboard is used for the storyboard, tap gesture recognisers are on UIImageview and using IOS 10.2.

Through different forums i have read about the following options:

  • nest the call of "present view controllers" in main thread
  • Call CFRunLoopWakeup before presentviewcontroller
  • Add programatically the TapGesturerecognizer
  • change the states of "delays touches end" and "delays touches began"
  • disable 3d touch option as similar symptoms was reported to happen in other apps

All above have been unsuccessful. Anyone would have met similar issues with the first tap just after the view load?

[Update: I realise this misbehaviour is not specific to this app. Two tests to try:

  • create an xCode Project for iPhone and two view controllers Controller A and Controller B. Two buttons : a button on Controller A view to go to Controller B view and a button Back in Controller B view to go back to Controller A view. Tap to go from View A to B, tap back in B and try immediately to tap on button to go to B. First tap doesn't work either.

  • Go in Settings of the iPhone. Tap On Notifications. Press On Settings to go back to Main Settings screen, Tap immediately back on Notifications. If fast enough, first tap doesn't work. Second tap works or waiting a bit before first tap.

Question is now: this looks like a common problem across iPhone apps. Would you know if there would be a common setting somewhere? or is this a common bug for given IOS version ? ]

Stephane

stephane
  • 172
  • 14
  • When do you add the tap gesture? – Larme Apr 09 '17 at 20:02
  • It is added through the storyboard, assumption is it is added without causing such misbehaviour, does it? – stephane Apr 09 '17 at 20:08
  • do you do networking or other long cpu intensive tasks in main thread? do you do animations? – Andre Apr 10 '17 at 20:52
  • Thanks . When switching from one screen to the next, i got 20% CPU peak then it goes back to 1%. Passive animations exist however the bug appears as well on views which do not have animations . From a networking perspective, i cut off all access to servers to test. Same behaviour observed.... – stephane Apr 10 '17 at 21:08
  • You're probably going to need to add minimal code that exhibits this behavior to this post before you get really useful answers. – Tad Donaghe May 11 '17 at 19:50
  • Hi, thanks for your message. I am using the storyboard for the whole creation process from uimageview, tapgesture recogniser to the method associated with the recogniser. All check boxes for interactions enabled are ticked... – stephane May 11 '17 at 21:03
  • Are you sure that your tap gesture recogniser is not waiting for another gesture recogniser to fail? – Reinhard Männer May 14 '17 at 15:42
  • Maybe you should try it programatically in the viewDidLoad or viewDidAppear. A simple tap gesture. –  May 15 '17 at 07:08
  • open the storyboard, on the imageView ensure that User Interaction Enabled is ticked. – torinpitchers May 15 '17 at 12:50
  • Adding a gesture recogniser doesn't work even programatically. User Interaction is enabled. – stephane May 15 '17 at 20:24
  • I believe the UINavigationController blocks user interaction during animation. The animation slows down a lot in the end and that may make it look like it has ended but maybe it is still going. Try disabling the animation when pushing the view controller and see if you still get the same behavior. – Marco Pompei May 16 '17 at 06:14

1 Answers1

7

This is a general problem (the moment when the view controller is changed, the first tap will be ignored), but this is not a bug that will happen only because the switch view controller's animation has not yet been completed. If you set the animation to false , then the view controller can immediately respond to your click, no matter how fast (anyway faster than your hand) :)

Kira
  • 243
  • 2
  • 9
  • Thank you so much ! Once animation is set to False , first tap started working even if the user taps very fast when the view just appears. – stephane May 16 '17 at 20:04
  • you should test it by code next time , code is always good at debug. – Kira May 17 '17 at 02:18