Daniel
Daniel

Reputation: 15

Getting the same coordinates from UIScrollView whether it's zoomed or not

Is it possible to get the same coordinates from UIScrollView whether it's zoomed or not.

That is, For example, consider a plain screen of 320.0F and 480.0F.

  1. Tap on a point; view will give me something like (60.0F, 80.0F).
  2. Zooming-in or zooming-out on the view so that it will have either bigger or smaller zoom scale but making sure the zoomed area to contain the point that was tapped which was (60.0F, 80.0F) according to previous zoom scale.
  3. Tap on the point again, the view will give me different coordinate value.

The Thing is, I want to have the same coordinate value whether the view is zoomed or not. The idea is simple. I want to show images zoomed & interactive without changing its coordinate. Considering an UIScrollView applied of the idea with its height of 1.0 and width of 0.66, I think there would be some pros programming this way, when making an interactive app without using OpenGL, cocos2d or whatever 3D engines out there.

Do you guys have any idea if it's supported or not? Either case, please don't wait any second to reply. Thanks

Upvotes: 0

Views: 654

Answers (1)

Ab'initio
Ab'initio

Reputation: 5418

You can calculate it by yourself using content size as follows,

  • x = (original_Width/ width_after_zooming) * point.x
  • y = (original_height/ height_after_zooming) * point.y

Upvotes: 1

Related Questions