Detecting Zoom Level on iPhone - iphone

I'm using the UIImagePickerController to control the camera and overlay millimeter tick marks in preview for measuring closeup macro shots, and I'd like to be able to detect the current zoom level and scale it properly.
Is there any way to determine the current zoom level in camera preview?

Unfortunately no, since the UIImagePickerController API doesn't give you access to the camera zoom level, nor to any subviews or other properties that might have access to that information.
As Michael Dautermann points out, based on the answer to this question, you could use the cameraViewTransform property of UIImagePickerController to implement your own zoom by setting up the right CGAffineTransform and also the right pinch gesture to zoom in/out. Since you'd be controlling the zoom yourself, you'd always know the zoom level and be able to use it to adjust the tick marks.

Related

Google Map SDK Swift, Zooming in and out like Uber's Map

I am trying to implement the Google Map SDK, and so far I have implemented a marker. I made the marker in a way that it follows as it is located in the center when I move the camera position.
The problem is that I can't zoom in and out while the marker's location is not changing. I would like to make the zooming experience like Uber in which the location does not change.. Thank you for your help.
You can use this line allowScrollGesturesDuringRotateOrZoom to your GMSMapview. It controls whether rotate and zoom gestures can be performed off-center and scrolled around. The default value of this is YES.
mapView.settings.allowScrollGesturesDuringRotateOrZoom = false // NO for obj-c and false for swift
So by setting it by NO/false, you can now perform zooming while the marker location is not moving. For more information, check this thread.

iOS MapKit - hide overlapping points?

I'm hoping for a straightforward way to display up to 200 points in a Map at once without degrading performance when the user is zoomed out and all of them are on the screen.
We have a draw order of priority and the most important ones are above the others. How can I hide the ones underneath until the user zooms into a specific area?
you can use these delegate methods to determine which region and the zoom level is being shown and show the points accordingly...
– mapView:regionWillChangeAnimated:
– mapView:regionDidChangeAnimated:
refer apple docs for more info..

How to snap to zoom with UIScrollView?

I have a UIScrollView with a content view that the user can zoom in/out. The min zoom level is less than 1, and the max zoom level is greater than 1.
It is easy for the user to zoom all the way in, or all the way out. What can I do to get the UIScrollView to snap to zoom level 1 as well? Not just when the the user lifts their fingers, but as the they are zooming in/out as well.
Write a method, that gets called every time the user stops zooming, which then checks to see if the current zoom scale is very close to 1.0 (like something between 0.8 and 1.2). If this returns true, the zoom scale is set exactly to 1.0 to snap.
The trick is to override or disable the pinch and add your own. When you start a pinch gesture, you DO NOT update the display and resize the image until the pinch is complete, then issue your zoomToRect.

How to implement pinch to zoom and flick with momentum for a drawing (graph) Core Graphics app?

In my app, I drew a graph using Core Graphics (inside a view, inside a view). Not a graphing calc app though, it graphs patient data and marks it every six months, and it is larger than the screen, so the user needs to have some way to move around. I was wondering if there is an easy way to implement pinch to zoom, or to flick with momentum. I was planning on just using UITouch to get notified when these actions were performed, but it doesnt really give you a lot of information. For example, all you get with the pinch to zoom is the ratio that they have zoomed, and all you get with the flick is the direction that they have flicked. So, I was just going to implement basic flicks without momentum, and simple pinch to zoom without being able to move around too.
But I figured I would ask here first, to see if anyone has a better idea about how to do this (easily).
EDIT: I found lots of places that tell you how to do this with photos, but none with core graphics or something like that, thanks.
I ended up using a UIScrollView, which implements pinch to zoom, and flick automatically (well, almost).

iPhone "Move and scale"... and rotate?

I am trying to find a way to make some way for users to adjust their images for my app. I tried default "Move and Scale" but it doesn't seem to support rotation.
what I want to do is making users to move, scale, and rotate the picture to fit in the overlay/silhouette. What should I do?
Have a look at the UIGestureRecognizer class available in iOS4. This can be used to detect certain gestures like rotation, panning & pinching. Once the gesture has been detected it's up to you to add the correct transform to the picture for instance.
The gesture recognizers really are the way to go, no more touchesBegan/Ended madness. But they come at a cost, as they are iOS4 only.
Link: UIGestureRecognizer Class Reference
Refer to this code by Erica Sadun - https://github.com/erica/iphone-3.0-cookbook-/tree/master/C08-Gestures/14-Resize%20And%20Rotate/