手势识别和自动布局在iOS6的,从中心缩放 [英] Gesture recognizers and auto-layout in iOS6, scaling from the center

查看:167
本文介绍了手势识别和自动布局在iOS6的,从中心缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这手势识别code以下,通常会从中心缩放视图,当自动布局在iOS6的启用不会。该观点似乎从扩展启用自动布局时,它的起源。其他仿射变换(尤其是缩放和旋转)也没有工作,我的预期。

任何人有这个问题,或者可以启发我来处理这个正确的方式?

   - (IBAction为)handlePinch:(UIPinchGestureRecognizer *){识别
    recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform,recognizer.scale,recognizer.scale);
    recognizer.scale = 1;
}


解决方案

通过自动布局你应该修改你的约束,因为转换和约束可以相互矛盾的......我有同样的问题,的在WWDC这会议上对我帮助很大。看看视频在30:35开始

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

解决方案

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

这篇关于手势识别和自动布局在iOS6的,从中心缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆