Search code examples
iphonecocoa-touchcore-animation

layer hit test only returning layer when bottom half of layer is touched


I have a sublayer on a layer-backed view. The sublayer's contents are set to an Image Ref and is a 25x25 rect.
I perform a hit test on the super layer when the touchesBegan and touchesMoved methods are invoked. The hit test method does, in fact, return the sublayer if it is touched, BUT only if the bottom half of the image is touched. If the top half of the image is touched, it returns the superlayer instead.

I do know the iPhone OS compensates for the tendancy of user touches to be lower than intended. Even if I resize the sublayer to a larger size, 50x50, it exhibits the same behavior.

Any thoughts?


Solution

  • Thanks Kevin...

    I ended up just redoing my code with UIViews. It was too much trouble just trying to figure out why the UIView didn't know what layer was being touched. My whole reasoning behind the idea was that I will have a 100+ items on screen at one time, and thought Layers would be easier on the processor than UIViews. I have the app up and running now and 100 views isn't giving it any hiccups.

    My suggestion to others is just stick with hit testing UIViews when possible, it makes the code much simpler