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

1

8

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;  
}
Jarred answered 21/9, 2012 at 9:40 Comment(6)
Did you ever figure this out? I am really stuck on this issue. Please comment.Beutler
@HenryHarris not sure because I stopped trying to use auto-layout, but I believe that if you create the view in question via code, and don't add constraints, that the gesture recognizer may perform as expected.Jarred
thanks. I am trying to use storyboards and cannot turn auto-layout off for one part of my storyboard without getting this error, Unable to simultaneously satisfy constraintsBeutler
@HenryHarris strange... I thought that was an autoLayout error, ie you would get it if AL was ON. In any case you should be able to resolve that, but I never use AL myself as of now. I always manually disable it when I start a project.Jarred
@Mrwolfy : hey. any solution to this issue?????Bibi
@Bibi yeah, disable auto-layout. I think when I wrote this I was trying to integrate auto layout into my devs, at this point I have abandoned it as it just seems to be too complex. I may revisit it soon.Jarred
C
3

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

Creep answered 24/10, 2012 at 6:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.