2

I have an image inside a ScrollView. It allows for pinch and zoom. It is also possible to rotate the image inside the ScrollView to a custom degree. When I do that, I lose the current zoom level of the image, and it reverts back to its 100% zoom and rotates. Is there a way I can maintain the zoom level while rotating the image?

I am doing this at the moment:

    UIScrollView* mainScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 80, 
                            self.view.frame.size.width, self.view.frame.size.height   )];

   self.pictureView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Image1.png"]];

    [mainScrollView setContentSize:CGSizeMake//(620,612)];
     (self.pictureView.frame.size.width, self.pictureView.frame.size.height)];
    [mainScrollView addSubview:self.pictureView];
    mainScrollView.minimumZoomScale = 0.5;
    mainScrollView.maximumZoomScale = 6.0;
    mainScrollView.delegate = self;   
    [mainScrollView setScrollEnabled:YES];
    [self.view addSubview:mainScrollView];
    [mainScrollView release];


-(void) rotatePicture:(float) value{
 self.pictureView.transform = CGAffineTransformMakeRotation(value );
}
Nicolás Ozimica
  • 9,481
  • 5
  • 38
  • 51
user542584
  • 2,651
  • 2
  • 25
  • 29

1 Answers1

1

Did you try:

-(void) rotatePicture:(float) value{
     self.pictureView.transform = CGAffineTransform CGAffineTransformRotate (self.pictureView.transform, value);
}

What this does is to preserve the zoom transform on the pictureView, and adds a rotate on top of it.

mahboudz
  • 39,196
  • 16
  • 97
  • 124
  • I think though that a further zoom will probably replace the transform with a plain scale one. You might have to manage the zoom yourself so you can always do it hand in hand with the rotation. – mahboudz Nov 08 '11 at 09:16