Iphone 防止旋转的CGA仿射变换被视图自动旋转破坏

Iphone 防止旋转的CGA仿射变换被视图自动旋转破坏,iphone,ios,ipad,ios5,Iphone,Ios,Ipad,Ios5,我有一个UIImageView的子类,其中包含一些手势识别器,我正在使用这些识别器将转换应用于自身。我在平移或缩放方面没有问题,但是当设备本身旋转时,旋转的变换会导致问题。基本上,每次旋转设备都会产生缩放图像的效果 我想这是有道理的,所有事物的旋转可能会导致旋转变换出现问题,但是有人知道这种行为的解决方法吗?最好是可以在UIImageView子类中实现的东西?我需要其他同级视图来自动调整大小,因此无法在父视图中禁用“自动调整子视图大小” 以下是负责创建旋转变换的代码(如果有帮助): - (voi

我有一个UIImageView的子类,其中包含一些手势识别器,我正在使用这些识别器将转换应用于自身。我在平移或缩放方面没有问题,但是当设备本身旋转时,旋转的变换会导致问题。基本上,每次旋转设备都会产生缩放图像的效果

我想这是有道理的,所有事物的旋转可能会导致旋转变换出现问题,但是有人知道这种行为的解决方法吗?最好是可以在UIImageView子类中实现的东西?我需要其他同级视图来自动调整大小,因此无法在父视图中禁用“自动调整子视图大小”

以下是负责创建旋转变换的代码(如果有帮助):

- (void)setUpRotation
{
    UIRotationGestureRecognizer *newRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotationGesture)];
    newRecognizer.delegate = self;
    self.rotationRecognizer = newRecognizer;
    [self addGestureRecognizer:self.rotationRecognizer];
    [newRecognizer release];
    self.userInteractionEnabled = YES;
}

- (void)handleRotationGesture
{
    // Initial state
    if(self.rotationRecognizer.state == UIGestureRecognizerStateEnded)
    {        
        lastRotation = 0.0;
        return;
    }

    CGFloat rotation = 0.0 - (lastRotation - self.rotationRecognizer.rotation);    
    CGAffineTransform currentTransform = self.transform;
    self.transform  = CGAffineTransformRotate(currentTransform,rotation);  

    lastRotation = self.rotationRecognizer.rotation; 
}
这是在iOS 5.0 btw上