I am using a scrollview and I am zooming my scrollview.
I want that if i zoom my scrollview only background imageview which in the Scrollview can zoom and a small image on scrollview should not zoom.
Consider a map , if i am zooming map the map zooms but a placemark on that map would remain as it is in terms of size and place..
Same thing i want with my scrollview.
Any help please?
you can add the image view on top of the zooming scroll-view. The order in which the sub-views are added will matter here. So, first add the scroll view that zooms and then the image view
Related
When I touch a UIScrollView, I zoom the view to a large scale. But the view is not centered to the place where I have touched. I want to know how to make the view center when I touch it, can someone give me some example code.
Or if the scrollview have had the function?
Before zooming, set the scrollview's contentoffset so the point you touched to be in the center.
I have a UIViewController that implements a UIScrollView with the UIScrollViewDelegate. Attached to it is an UIImageView for which the user must crop the photo via zooming it and panning to fill the entire length of the screen. After the user has finished cropping and they hit done, the original UIImage gets sent to the next UIViewController.
I'm wondering, is there anyway, using the original image, to display it in a UIScrollView and allow the user to zoom and pan it so ONLY the cropped area gets shown? IE none of the image that was outside of the cropped area gets shown in zooming and panning? Is there a way to do this without explicitly cropping the image?
This might head you in the right direction: Displaying part of an image
Not to sure if this will work with the way you are displaying it. But if it does it could be a simple solution. You can also read through UIScrollviews and maybe use panGestureRecognizer and pinchGestureRecognizer to limit the area they can zoom and pan.
Set the content size of the UIScrollView to the rect of the cropped area.
I have an Image View and I need to be able to pinch-zoom it, scroll it when it is zoomed and also rotate it with two-finger.
Initially I used a scrollView and added ImageView to it. but ImageView wasnt getting rotation gestures as ScrollView was intercepting them.
So I added the gesture to the ScrollView started rotating the scrollView itself.
Things work fine but rotated scrollView doesn't look good.
So I made the ScrollView get the rotation gesture but rotated the imageView in it instead of ScrollView.
But Now, the problem is If I rotate the image and then zoom and again try to rotate, previous rotation is lost and same when I rotate the previous zoom level is lost.
How should I go about it ? Is the scrollView unnecessary ?
i'm trying to place a UIView on a scrollView during its zoomed state. I want the UIView to be seen on the scrollView and also to resize along with it once the scrollView is zoomed out.. i am able to place the UIView on scrollView during the zoomed state. But the UIView is not getting resized after zooming out... Should i apply any transforms here??? can anyone help me in this please... Thank you
You can use a little trick: before zoom is started get the screenshot of the view (with subviews) that you want to zoom. Add that image to the UIImageView add return it via viewForZoomingInScrollView:. So you actually zoom the image of that view and not the one itself.
After zoom ended scale your actual view manually.
You can find out how to get screen shot from my post here
I'm trying to understand how UIScrollView works for zooming.
I was trying to rotate a UIImageView within a zoomed UIScrollView and I ended up with weird sizes, my centering in the scrollview not working anymore.
I solved the problem by setting the zoomScale to 1.0 before doing the rotation, and then by resetting it back to the previous value once the transformation was done.
I was wondering what was the impact of the UIScrollView on its subviews. Does it change their sizes, their positions. Or is it simply the UIScrollView that handles the zooming and the drawing of the zoomed subviews.
I realise that is an old question, but I thought I'd add additional information for those still arriving here like myself.
The scroll view manages its contents view, it zooms by adding tranformations to the content. So, for an image when you zoom in, it uses a tranformation to scale the image to the required zoom level.
When you are panning/scrolling a ScrollView, it changes the zoom level and origin positions to move the content around. So the content may well be larger than the scrollview itself. It clips the content at the scrollviews bounds and just adjusts this origin position.
The central notion of a UIScrollView object (or, simply, a scroll view) is that it is a view whose origin is adjustable over the content view. It clips the content to its frame, which generally (but not necessarily) coincides with that of the application’s main window. A scroll view tracks the movements of fingers and adjusts the origin accordingly. The view that is showing its content “through” the scroll view draws that portion of itself based on the new origin, which is pinned to an offset in the content view. The scroll view itself does no drawing except for displaying vertical and horizontal scroll indicators. The scroll view must know the size of the content view so it knows when to stop scrolling; by default, it “bounces” back when scrolling exceeds the bounds of the content.
Source Documentation