On Jul 18, 2014, at 4:51 AM, 2551 <2551p...@gmail.com> wrote: > I have a problem which I can't find anyone else asking after hours of > searches through stackexchange and the like. > > In a UIView, I'm rotating a subview with a Gesture recognizer that calls this > selector: > > - (IBAction)rotateShape:(UIRotationGestureRecognizer *)gesture { > gesture.view.transform = CGAffineTransformMakeRotation(gesture.rotation); > } > > The rotation performs as expected and all is right with the world. However, > as soon as I attempt to touch or move the rotated subview again (it also has > a pan gesture), it reverts to its original orientation.
No, when you apply a transform to a view, it becomes _the_ transform; it isn't retaining previous translation state. Based on what you've said, it sounds like when you touch/move the object that you're applying a translation transform to the view. > It seems the original transform values are still being retained and held by > the object or by the drawing context (I'm still not quite comfortable with > all the graphics theory; indeed, this is my first attempt at trying to unlock > its mysteries). You may already know this but the CFAffineTransformMake*() functions apply a single operation (rotate, scale or translate) to the identity transform. If, for example, you called CGAffineTransformMakeRotation() and then later CGAffineTransformMakeTranslation(), then the rotation will be lost. > What else do I need to do to ensure the new rotated, orientation "sticks" so > that I can move the shape without it reverting to the original orientation? Keep track of translation and rotation values in your model and then build translated+rotated transforms that reflect the current state of each object. - (IBAction)rotateShape:(UIRotationGestureRecognizer *)gesture { modelObject = ...; modelObject.rotation = gesture.rotation; gesture.view.transform = [self transformForModelObject:modelObject]; } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com