PDA

View Full Version : CGRectContainsPoint on animating UIView vs UIImageView




99miles
Dec 3, 2008, 08:27 PM
I'm curious why CGRectContainsPoint works on an UIImageView while it is animating but not on an UIView while it is animating?

I have a square moving across the screen and as it's moving I want it to stop if I touch it. It works with a UIImageView but not UIImageView.

Why is that?

I need more than just an image, so should I be looking into CALayer as opposed to UIView?

Thanks for any guidance!



99miles
Dec 3, 2008, 10:10 PM
I take that back, it doesn't work either way. I thought it did but it turns out it only worked when I clicked where the frame of the image was animating to, even if the image wasn't there yet.

So, how can I detect which uiview a touch occurs on when the uiview is in the middle of animating? I have been looking at the Touch example, but my scenario is different in that there are a bunch of views to check, and not just 3 as there are in the sample.

I'm using CABasicAnimation to animate the position.y, then setting the frame to the destination location. The problem is that during the hitTest the views return the destination frame and not their current location in midst of animating.