0

I am implementing cropping feature from scratch, which has the following structure

                                BaseUIView
                                 /    \
                                /      \
                               /        \
                              /          \
              CropUIView,EdgeUIView     ScrollView
                                           |
                                           |
                                           |
                                        ImageView

I have a couple of cropping handles which can be dragged to enlarge/diminish the cropping window (i.e. change the size of CropUIView and EdgeUIView accordingly).

I have kept the CropUIView hidden so that I can provide Pinch-Zoom feature for the image in the ImageView. Currently, I am dependent on the ScrollView and its delegates to help scroll/zoom the image.

What I need to implement is, when the user pinches on the EdgeUIView (the greyed area as shown in the image below), the image should zoom in/out the way it does when I pinch on the clear area.

I am aware that this kind of functionality may not make sense.

Sample Image

decached
  • 915
  • 1
  • 10
  • 24
  • Why you decided to refuse from scrollView? – Roma May 27 '14 at 06:39
  • The scrollView works perfectly fine, however, since the scrollView is below the edgeView, it doesn't receive the touch and the scroll/zooming doesn't work. – decached May 27 '14 at 06:49
  • What if you subclass efgeView from scrollView or make it conform to UISCrollview delegate? – Roma May 27 '14 at 07:02
  • If I were you, I'd drop the UIScrollView and implement pinch zoom and touch scroll functions in the BaseUIView (or derived custom view) class. It would require under 300 lines of code. – 9dan May 27 '14 at 07:04
  • Also look at this link about forwarding touch events http://stackoverflow.com/questions/3834301/ios-forward-all-touches-through-a-view – Roma May 27 '14 at 07:05
  • @Roma, Then the edgeView would zoom along with the image. I'll look into the forwarding of touch events' link. – decached May 27 '14 at 07:23
  • @9dan, simulating pinch-zoom would be an overkill. – decached May 27 '14 at 07:24
  • @AkashKothawale Also you can look on some ready solutions. https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=crop. You can look how other did this and replicate behaviour on EdgeView – Roma May 27 '14 at 07:39
  • Got the answer. Disabled `userInteraction` for the EdgeView. Thanks. – decached May 29 '14 at 09:46

1 Answers1

0

Perhaps the structure of my UIViews is messed up, but the solution that worked, comes from:
Make UIView pass through touch events?.

I simply had to disable user interaction on the EdgeView to make the touch events pass through.

Community
  • 1
  • 1
decached
  • 915
  • 1
  • 10
  • 24