views:

310

answers:

1

I have a UIScrollView with zooming and panning. I want the image to scroll to the center after a user command. My problem is in calculating the size and location of a frame that is in the center of the image.

Does anyone know how to calculate the correct frame for the center of my image? The problem is that if the zoomScale is different the frame changes.

Thanks!

A: 

Okay, got it working. Here's the code incase anyone is in need:

CGFloat tempy = imageView.frame.size.height;
CGFloat tempx = imageView.frame.size.width;
CGRect zoomRect = CGRectMake((tempx/2)-160, (tempy/2)-240, myScrollView.frame.size.width, myScrollView.frame.size.height);
[myScrollView scrollRectToVisible:zoomRect animated:YES];
Jonah