简体   繁体   English

在不使用手势识别器的情况下,通过轻按外部来缩小视图

[英]Shrink a view based on tapping outside, without using gesture recogniser

I have three containers in my landing screen one below the other. 我的着陆屏幕中有三个集装箱,一个在另一个的下方。 The bottommost Container has a behaviour to increase its height based on Tap inside its bounds. 最底部的容器的行为是基于其边界内的Tap来增加其高度。

Now, once I tap anywhere on the screen - including the bounds of the said container as well as the other two containers, I want to shrink the container back to the original height. 现在,一旦我在屏幕上的任意位置点击-包括上述容器以及其他两个容器的边界,我都希望将容器缩小到原始高度。

I am currently doing this by adding a bunch of tap gesture recognisers on the other three containers and checking a boolean value (isShrunk) to do the shrinking. 我目前正在通过在其他三个容器上添加一堆轻击手势识别器并检查布尔值(isShrunk)来进行缩小来实现此目的。 However these gesture recognisers seem unnecessary as all I want to do is on the next touch after the view is increased in height I want to shrink the view. 但是,这些手势识别器似乎没有必要,因为我只想在视图增加高度后单击下一个触摸,即可缩小视图。

我可能不太了解您的需求,但是简化它的一种方法是重构代码:一个带有您的轻击手势识别器的父视图类,以及将三个容器作为父子类,即您将手势管理集中在一个地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM