我有一個UIScrollView
具有縮放UIImageView
,即它實現:在ScrollView中旋轉縮放ImageView?
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.imageView;
}
我想一個UIRotationGestureRecognizer
添加到此imageView
,我做如下:
_rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
[self.imageView addGestureRecognizer:_rotationGestureRecognizer];
-(void)rotate:(id)sender
{
UIRotationGestureRecognizer *rotationGestureRecognizer = [(UIRotationGestureRecognizer*)sender retain];
if(rotationGestureRecognizer.state == UIGestureRecognizerStateEnded)
{
self.lastRotation = 0.0;
return;
}
CGFloat rotation = 0.0 - (self.lastRotation - rotationGestureRecognizer.rotation);
rotationGestureRecognizer.view.transform = CGAffineTransformRotate(rotationGestureRecognizer.view.transform, rotation);
self.lastRotation = rotationGestureRecognizer.rotation;
[rotationGestureRecognizer release];
}
我我只是想知道,是否有可能做到這一點?看起來UIScrollView
阻止了我的UIImageView
,因爲什麼都沒有發生。 Apple建議不要在UIScrollView
的縮放視圖中執行此操作嗎?
使用KTOneFingerRotationGestureRecognizer旋轉 –
@CoDEFRo如果你想旋轉滾動視圖,然後用添加手勢滾動視圖。 – Warewolf