I have a scrollview to which I have added an image view as a subview. The contentsize of the scrollview is same as the size of the imageview (width and height). There are two buttons outside the scrollview. When I click on either on them, a small rectangle view is added as a subview to the imageview. This rectangle view can be dragged anywhere on the imageview by the user after it has been added.
This works fine until I pinch to zoom the scrollview. In the viewForZoomingInScrollView: method, I return the imageview and the zooming works fine. But in the zoomed view when I try to drag around the rectangle view, it does not move. It does not recognize the pan gestures any more. Any idea why this is happening?
Thanks
Hetal
Following up to your last comment, I’d suggest to try the following:
In your
viewDidLoadmethod add this:where dragView is your rectangleView.
The following is probably not necessary for the above to work, but it might be good practice to clean up the view hierarchy anyway:
Add a plain UIView as superview of your image view with the same frame and add the rectangle view as subview of that new view. In your
viewForZoomingInScrollView:return that new view. As I said in the comments I don’t think adding subviews to UIImageViews is considered good practice. But maybe that’s just my opinion 🙂