Handling touch events in uiscrollview - iphone

I have a UIScrollView and an UIImageView as its subview. I want to draw on the imageview in response to the single touches. And I want to zoom and pan the image view in the scroll view on pinch and pan gestures respectively. I found many solutions. But its not perfect. Please give me a straight forward solution.

use after subclassing UIScrollview.See the link.If you are doing application for iphone4 OS,try to use UIGestureRecogniser.see the sample code for it in Apple site.

If you are only using the scrollview for panning and zooming, I would suggest subclassing UIImageView to provide that functionality yourself along with the drawing. This will allow you to have finer control over it and quicker code. A scrollview is not very good at allowing complex gestures within it. (other than taps)

Related

Scroll screen without using UIScrollView

I've seen iOS apps that allow users to scroll around a view that is larger than the screen itself, without seeming to implement a UIScrollView mechanic. So for example, the actual image displayed on the screen is double the width of the screen, and the user can pan left and right to view all the content. Is this just a case of making the ViewController's width twice that of the screen and allowing some kind of panning via gesture recognizers? With what I'm trying to do, it seems like this would be easier that implementing a UIScrollView...
Implementing scrollview is much easier than handling pan gesture, when Apple has given built-in functionality then why you do not want to use it?
You can either use UIPangestureRecognizer or UIscrollview. The Latter option is very simple.

How to detect horizontal swipe gesture on the custom UIScrollView?

I created custom UIScrollView and add UIImageView.
I want to detect horizontal swipe gesture on the UIScrollView, but I cannot do it.
I cannot find any other references in my case.
I found only following url, but it's not real detecting gesture.
How to recognize swipe gesture in UIScrollView
I've not any zoom effect.
Please help me.
Doesn't one of the UIScrollViewDelegate methods such as [UIScrollViewDelegate scrollViewDidScroll:] work for you? I don't know your specific case, but standard way of detecting swipe action in UIScrollView should be through its delegate.

Performance Issue with Scrollview above MapView

We are developing a map based application which displays large number of annotations above the map using MKMapKit.
We are using a scrollview placed above MapView for differentiating between pinch and drag gestures. We are able to differentiate between pinch and drag but the responsiveness of the Application becomes sluggish while dragged.
We will appreciate any suggestions for improving responsiveness of map while using the scrollview above MapView.
Thanks in advance.
Combining MKMapView and UIScrollView was always a bad idea. Try not to use it. Use UIView with gesture recognizers over the map instead.

how to pinch image in iphone

Hi I am new i want to develop a application that we zoom in and zoom out image but i am not understand how to do this. any one help me with code and other
For iPhone OS 3.2 or higher, use the bundled gesture recogniser UIPinchGestureRecognizer.
In my opinion the easiest way would be to add an UIScrollView to your viewcontroller which will be the scrollviews delegate.
Then you'll implement the viewForZoomingInScrollView UIScrollViewDelegate method where you'll return the UIImageview that has to be zoomed/pinched.
You would also need to set the maximumZoomScale and minimumZoomScale properties of the UIScrollView.
UIScrollView documentation
UIScrollViewDelegate documentation
A scroll view also handles zooming and panning of content. As the user makes a pinch-in or pinch-out gesture, the scroll view adjusts the offset and the scale of the content. When the gesture ends, the object managing the content view should should update subviews of the content as necessary. (Note that the gesture can end and a finger could still be down.) While the gesture is in progress, the scroll view does not send any tracking calls to the subview.
The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum ( minimumZoomScale) zoom scale must be different.

How to zoom image in iPhone?

I need to zoom an image in iphone...while the user double clicks on the image it will be zoomed in and on the next click it will be zoomed out....Can anybody direct me to how to do this???
You would probably have to use the size property of UIImage, triggered by UIImageView's touchesBegan method.
You can also use animations if you want the zoom effect to be smooth.
Another option could be to place your UIImageView inside a UIScrollView, or use a UIWebView.
Also, I suggest you take a look at the Three20 project. I think TTPhotoView supports zooming.
If you want to zoom and scroll your view, you need a UIScrollView. Tricking it to do what you want used to be very hard, however the problem of programmatic zooming of UIScrollView is now solved.
I have a described how to do it, created ZoomScrollView class (a drop-in subclass of UIScrollView) to encapsulate the solution and provided a working example at github.com/andreyvit/ScrollingMadness/ (the README contains a long description of two UIScrollView tricks and the reasoning behind them).