具有两个图像的UIScrollview-保持1个图像可缩放和1个图像静态(固定大小) [英] UIScrollview with two images - Keeping 1 image zoomable and 1 image static (fixed size)

查看:51
本文介绍了具有两个图像的UIScrollview-保持1个图像可缩放和1个图像静态(固定大小)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIView ,其中包含可缩放的 UIImageView ,并在其顶部还包含另一个半透明的 UIView .

I have a UIView which contains a zoomable UIImageView and also another semitransparent UIView on top of that.

我想要实现的是能够缩放 UIImageView ,同时保持半透明视图静态且不缩放.

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

如果我将半透明的 UIView 添加到 UIImageView (已添加到 UIScrollView )的顶部,则所有内容都会缩放.但是,如果我将两个都作为子视图添加到基本的 UIView 中,则自从最后一个添加以来,仅跟踪的触摸是半透明的 UIView .

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.

我确实需要控制控件以使其首先位于半透明的 UIView 上,因为我可能想调整半透明的视图的大小.但是,如果要使用两个手指,我想将触摸的控制权传递给 UIScrollView .反正我有实现这一目标的方法吗?nextresponder似乎不起作用.除了对 UIWindow 进行子类化外,我还尝试使用hittest,但是基本的 UIView 需要推/弹出导航控制功能,所以我认为我不能对进行子类化UIWindow 插入导航堆栈.

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.

任何帮助将不胜感激.

谢谢

温斯顿

推荐答案

嗯.您可以尝试使用此层次结构(可能是子类):

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

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

像这样,覆盖层无法缩放.

Like this, the overlay does not scale.

然后,棘手的事情是多层用户交互.如果叠加层中存在不应检测用户触摸的区域,这很容易,因为您只需将应将触摸转发"到底层的视图部分的UIView属性"userInteractionEnabled"设置为"NO"即可.

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.

但是,如果我说对了,您就需要更复杂的东西.您可能可以在容器UIView中设置某种master-touch-controller,以找出正在发生的情况,然后调用其子视图的某些方法/转发事件.我不知道您需要在容器中覆盖/实现所有确切的方法,但是请从

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?

这篇关于具有两个图像的UIScrollview-保持1个图像可缩放和1个图像静态(固定大小)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆