views:

222

answers:

1

Hello, m I have a UIView which contains a zoomable uiimageview and also another semitransparent uiview on top of that.

What I am trying to achieve is to be able to zoom the uiimageview while keeping the semitransparent view static and not zoomed.

If I add the semitransparent uiview on top of the uiimageview (which is added to the UIScrollview), everything zooms. However, if I add both as subviews to the base UIView, the touches only get tracked is the semitransparent uiview since its the last one added.

I do need control to reside first at the semitransparent uiview for the touches since I may want to resize the semitransparent view. However, I'd like to pass control of the touches to the UIScrollview if two fingers are used. Is there anyway for me to achieve this? The nextresponder doesn't seem to work. I also tried to use hittest in addition to subclassing UIWindow, but the base UIView needs to push/pop navigation controlling ability so I don't think I can subclass UIWindow to push onto the navigation stack.

Any help would be appreciated.

Thanks, Winston

A: 

Hm.. you can try this hierarchy (possibly subclasses):

UIView (container)
 > UIView (semitransparent overlay)
 > UIScrollview
   - UIView (zoomable content)

Like this, the overlay does not scale.

The tricky thing then is the user interaction on multiple layers. Its easy if there are areas in your overlay that should not detect user touches, for that you just set the UIView property 'userInteractionEnabled' to 'NO' for the view parts where touches should be 'forwarded' to the underlaying layers.

But if I get you right, you need something more complicated. You probably could set up some kind of master-touch-controller in the container UIView, that finds out what is happening and then calls certain methods of its subviews / forwards the events. I don't know all the exact methods you need to override/implement in the container, but check out the tapZoom demo from the ScrollView Suite sample code. It's a pretty nice example there.

Just out of curiosity, may I ask what this interaction model is used for?

Efrain
Hello Efrain,Thanks for your response.Basically the effect I'm trying to achieve is to have an image with a darkened semitransparent layer on top of the image. This darkened layer contains a rectangular box which can see through to the original layer(become clear). This cropping box which can be adjusted by the corners.I hope this helps explain. I believe I tried your solution and will try again, I remember it didn't quite provide the effect I was looking for and washed out the mask layerReally appreciate your help :)Winston
Winston
btw.. regarding what kind of touch events are being forwarded etc., maybe you could read through this:http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html
Efrain