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.
Related
I have a zoomable UIScrollView which contains a custom drawn view (two circles). When the view is zoomed, I want to know where the centres of the circles lie, wrt the App's window. Consider these steps:
The view at 1X
The view zoomed at an arbitrary level, with the pinch focused on the first circle
The view zoomed at an arbitrary level, with the pinch focused on the top right corner
What I am meaning to ask is, if I were to lay another view containing a circle on top of the scroll view such that the circle in this view is concentric (need not be of the same size) with the smaller circle in the scroll view's view, where should the centre of the new circle be located?
When using UIView's coordinate conversion methods it is not relevant that you custom view is embedded in a scroll view:
MyCustomCircleView *circleView;
CGPoint centerInLocalCoordinates = circleView.centerOfACircle;
CGPoint centerInWindowCoordinates = [circleView convertPoint:centerInLocalCoordinates
toView:nil];
Maybe window coordinates are not what you are looking for. Remember that the window's coordinate space is always in portrait orientation and with the home button at the bottom. When holding the device in landscape orientation, your coordinates are (of course) rotated.
It might be easier to convert to a superview's coordinates, for example your view controller's view's coordinate space.
Did you draw the circles? Some combination of scrollView.contentOffset, scrollView.contentSize, and scrollView.zoomScale is what you want. You can walk back the translation and scaling using those values.
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
What I want to do is an horizontal scroll view with buttons inside and when A button came at the center of the screen it became bigger. How can I do this?
Intercept the delegate method for scrollViewDidScroll: and monitor the scrollviews contentOffset. Doing so will allow you to make any adjustments each time the scrollview moves. As your button.center moves closer to your scrollviews center, increase its frame.size. Be sure not to do anything overly complex in scrollViewDidScroll bc it will be called a lot.
I have a UIScrollview.I want it to scroll only when I move my fingers in a particular region in the scrollview unlike the usual way.is it possible?. Please help
Handle with touches, detect a swipe event and then scroll the ScrollView thro' coding.
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