Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gesture recognizers and auto-layout in iOS6, scaling from the center

This gesture recognizer code below, which normally would scale a view from the center, does not when auto-layout is enabled in iOS6. The view seems to scale from it's origin when auto layout is enabled. Other affine transformations (particularly scale and rotate) are also not working as I expected.

Anyone have this issue, or can enlighten me to the right way to handle this?

- (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer {    
    recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
    recognizer.scale = 1;  
}
like image 711
Mr Ordinary Avatar asked Sep 21 '12 09:09

Mr Ordinary


1 Answers

With Autolayout you should edit your constraints because transforms and constraints can be conflicting... I had the same problem and this session at WWDC helped me a lot. Take a look at the Video beginning at 30:35

like image 194
sensslen Avatar answered Sep 22 '22 11:09

sensslen