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

删除回忆录丶 提交于 2019-12-21 04:29:32

问题


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;  
}

回答1:


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



来源:https://stackoverflow.com/questions/12528019/gesture-recognizers-and-auto-layout-in-ios6-scaling-from-the-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!