Zoom the page of a view based iOS App - iphone

I have a view based application. I have to add features like pinch zoom and double tap to zoom the page(UIView) in the iOS application. Its easy to zoom a UIScrollview.
I should create a framework which has the option to pan and zoom the entire app. How do a achieve to zoom a view based application? I welcome your ideas!

The best way to do it, is to put the entire app components in one scrollview and use the zooming of the control.
The other way which is not as stable as the first one, is to scale all objects inside the UIVIEW larger or smaller depending on the pinch zoom, but keep in mind that scaling will affect the look of the entire application, so you need to adjust the position of each object accordingly.

You can create your own zoom functionalities in a UIView by using UIGestureRecognizer and CALayer transform property. Ex. scaling and change the anchorPoint base on the focus point.

Related

How to zoom a selected area of image like pupil meter?

I have to show in zoom of a selected area of image continuously. Means if you are changing position simultaneously zoom also to be change. I don't know how to implement this.
UIScrollView has a great method - zoomToRect:animated: - that allows you to zoom on a specific rect. If you have a UIImageView sitting on a UIScrollView then you can zoom around the image view using this one simple method.

iOS zoom algorithm

I am creating a graphing calculator application in OpenGL on iOS, and I would like to implement pinch zooming that works like the google maps application or uiscrollview zooming. I'm pretty sure I can't use a uiscrollview because the content of the graph is being generated dynamically.
Implementing zooming where the center of the screen is assumed to be the center of the zoom is easy, but in other cases it is not obvious to me how its being implemented. Can anyone point me in the right direction?
The view that does your custom drawing should be capable of drawing at a certain scale. When your user zooms in or out of the scroll view, send the appropriate zoom factor and let the view redraw itself. The changing bounds is not a problem. The scroll view adjusts its bounds as you pan inside, so its subviews shouldn't have any concern over the bounds of the scroll view.
Of course, you'll probably have to consider performance. For example, it may be too slow to redraw the graph at every frame as a user zooms. Instead, you may only want to redraw when the user stops zooming, which is what Maps.app does.
There are many other considerations for this problem, but that would be where I would start.
EDIT: Ah, I overlooked the OpenGL aspect. Still, with a GL layer-backed view, you still should be able to make the appropriate translations based on both the current zoom factor as well as the scroll view's bounds.

Zoom in out a view to a specific point iphone sdk?

I want to zoom in and out a UIVIew on to specific point something similer effect to focus + zoom in. I don't want to use UISCrollView. What is the right approach to do this if anyone could suggest.
Thanks
The right approach is to use a scroll view. If you don't want to use a scroll view, though, you can use a tiled layer. Bill Dudney has an example of that here: http://bill.dudney.net/roller/objc/entry/tiledlayer_on_the_iphone
Why don't you want to use a scroll view?

UIScrollView map with pins that stay at a fixed size?

In my app, I have a ScrollView that shows a map(just a jpeg).
On top of the ScrollView, I added some pins(UIImageView)
So far so good.
But when I zoom in, the pins also get larger.
I would like the pins to stay at a fixed size, just like the pins on the google map application on the iPhone.
How do I solve this?
Thanks!
I've been looking into this for a few days and I've come to the conclusion that there is currently no good way to do this.
First, put your pins as a direct subview of the UIScrollView. Now they'll stay the same size, but will move around when you zoom.
In OS version >=3.2 in UIScrollViewDelegate there is -scrollViewDidZoom:, where you can update the pins to the right coords as it scrolls, and this works great. But in 3.1 we're out of luck. I tried having a NSTimer going and updating the coords instead, but it's not performant on the device.
As a fallback what I do is hide the pins when zooming starts (viewForZoomingInScrollView) and when zooming ends (scrollViewDidEndZooming) update their coords and unhide them.
Make a container UIView that is the same size as the map. Add the map to the UIView with autoresizing of flexible width and height. Add all the pins as individual images, each with flexible margins. Use the container as the zooming view.
If the system autoresizeing does not retain the margin ratio then you can implement layoutSubviews in a custom container view.

How do I reset (i.e. un-zoom) a UIScrollView?

I have a UIScrollView that contains an image and a segmented control that allows the user to switch the image inside of the ScrollView. If I just swap the image out inside of the UIImageView, it will display the new image in the zoomed-in state. How do I reset the UIScrollView back to its un-zoomed-in state?
I have a detailed discussion of how (and why) UIScrollView zooming works at github.com/andreyvit/ScrollingMadness/.
(The link also contains a description of how to programmatically zoom UIScrollView, how to emulate Photo Library-style paging+zooming+scrolling, an example project and ZoomScrollView class that encapsulates some of the zooming magic.)
Quote:
UIScrollView does not have a notion of a “current zoom level”, because each subview it contains may have its own current zoom level. Note that there is no field in UIScrollView to keep the current zoom level. However we know that someone stores that zoom level, because if you pinch-zoom a subview, then reset its transform to CGAffineTransformIdentity, and then pinch again, you will notice that the previous zoom level of the subview has been restored.
Indeed, if you look at the disassembly, it is UIView that stores its own zoom level (inside UIGestureInfo object pointed to by the _gestureInfo field). It also has a set of nice undocumented methods like zoomScale and setZoomScale:animated:. (Mind you, it also has a bunch of rotation-related methods, maybe we're getting rotation gesture support some day soon.)
However, if we create a new UIView just for zooming and add our real zoomable view as its child, we will always start with zoom level 1.0. My implementation of programmatic zooming is based on this trick.
If you're not redrawing your view on the completion of the pinch zooming event, then the zoom factor is being set by the transform property of the view you return from the viewForZoomingInScrollView: delegate method. To reset this zoom, set the value of the view's transform property to CGAffineTransformIdentity.
Beware, though, that your next pinch-zooming operation will start where the previous pinch-zoom left off (that is, your new scale will be ignored). To work around this, you may need to implement some of what I describe here.