1

I have a UIView which has several subviews that respond to touch. If I rotate the layer of the superview with some code like this:

[CATransaction begin];
[CATransaction setDisableActions:true];
view.layer.transform = CATransform3DRotate(view.layer.transform, angle, 0, 0, 1);
[CATransaction commit];

... then I can't seem to find the right location of the subviews when responding to touch events... Any ideas?

4
  • Use NSLog(@"%@", subview.view); to locate the problem
    – Alby
    Jan 5, 2012 at 0:40
  • Seems like the subviews think they are still in the same place. I'll keep trying... Jan 5, 2012 at 0:54
  • Could it be that the layer's transform property be different from it's UIView's? Jan 5, 2012 at 1:18
  • Part of the problem seems to be that I am using a bezier for hit detection in my subviews. Could it be that the bezier needs to be updated for the transformation... I tried some code in that way since UIBezierPath has an applyTransform method, but it is not helping the way I am doing it right now... Jan 5, 2012 at 1:47

1 Answer 1

3

I found it, worked out beautifully I guess. I needed to convert points between UIViews for doing bezier hit testing:

-(BOOL)containsPoint:(CGPoint)point
{
    point = [self.superview.superview convertPoint:point toView:self];
    return [self.slicePath containsPoint:point];
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.