Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with gesture recognizer in iOS 7
    primarykey
    data
    text
    <p>I'm adding several <code>UIView</code> objects (e.g. 5) to the screen, one inside the other. This, for example, <code>view5.superview = view4</code>, <code>view4.superview = view3</code>, <code>view3.superview=view2</code>, <code>view2.superview = view1</code>. For all these <code>UIView</code> I set uitapgesturerecognizer; for view1-4 I just do NSLog(@"tap %@", self) in callback, while for view5 tap I set the following: delete view4 from the hierarchy, then put the same object view4' at the same place of the hierarchy. This object also contains view5' for which <code>UITapGestureRecognizer</code> is set (practically, I replace one part of markup with similar one). </p> <p>Then I start clicking on view5. Some time view5 keeps catching its tap and everything's OK, but random number of taps later (every time this number is different) one of the view1-4 objects starts catching this tap, though we're still clicking the view5. The whole problem has a random character - sometimes it occurs at the 10th launch, sometimes at the second. Sometimes wrong objects start catching taps at the first tap. Also I never know what object will catch a tap, when everything goes wrong. The frame for view(n+1) was set, e.g., as a half of the frame view(n), while the frame for view1 - e.g. (0,0 320, 460).</p> <p>All operations with ui objects described above are conducted in the main thread, and everything I've told about perfectly worked on iOS 4.3 - 6.1 with much more complex examples. But the iOS7 makes out of it some kind of a random hell.</p> <p><strong>Update:</strong> I've created a sample project, to simplify the debug process. No add/remove subview operations on tap. Only 4 views on screen, on tap the app logs what view was tapped. So, you need to tap on smallest view (4). If you see "tap 4 tap 4 tap 4…" in the log - this is the case when everything works fine, stop and run again, stop and run again, stop and run again, etc. And at some runs (maybe after 10+ successful runs) you won't see "tap 4" on the first line, you will see "tap 1" or "tap 2" or "tap 3", and it will continue so - these are the bad cases.</p> <p>Sample project can be downloaded from here: <a href="http://tech.octopod.com/test/BuggySample.zip" rel="nofollow noreferrer">http://tech.octopod.com/test/BuggySample.zip</a> (just 33 Kb in archive).</p> <p><strong>Update 2</strong></p> <p>We've posted a bug to Apple, I'll post here when we will get some feedback. However, any good workaround would be much appreciated!</p> <p><strong>Update 3</strong></p> <p>Solution, provided by Yuvrajsinh is really working on the sample project. Unfortunately, it still does not help to solve the problem that occurred in the main project where it initially appeared. The main reason for now is that if any view without self gesture is laying upon the clickable content, random view element under it starts catching the interaction (instead of the top one with interaction gesture set. Do you have any ideas how it can be solved? The updated sample can be downloaded from here: <a href="http://tech.octopod.com/test/BuggySample2.zip" rel="nofollow noreferrer">http://tech.octopod.com/test/BuggySample2.zip</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload