0

I have some imageviews that should rotate 90° every time they are touched. This is my code:

- (void)handleTap:(UITapGestureRecognizer *)tapRecognize
{
    if (tapRecognize == tapRecognizer)
    {
        CGAffineTransform transform = CGAffineTransformMakeRotation(90);
        lineImage.transform = transform;
        [lineImage setTransform:transform];
    }    
}

This only rotate it first touch, how to I make it rotate 90° more when its taped again?

4

1 回答 1

0

您应该首先获取 lineImage 的当前变换,然后将其旋转 90 度。以下代码将解决您的问题

   - (void)handleTap:(UITapGestureRecognizer *)tapRecognize
    {
        if (tapRecognize == tapRecognizer)
        {
            CGAffineTransform transform = CGAffineTransformRotate(lineImage.transform, 90);
            [lineImage setTransform:transform];
        }
    }

并确保您已启用 imageviews 的 uesr 交互,

  [imageView1 setUserInteractionEnabled:YES];
  [imageView2 setUserInteractionEnabled:YES];
于 2013-04-27T16:26:41.053 回答