按钮被另一个按钮覆盖,因此无法轻敲

时间:2016-11-20 07:30:32

标签: ios swift uiview

屏幕上显示smallButtongiantButton,开始时未启用giantButton,点击smallButton时,隐藏giantButton出现。

我的问题是,似乎smallButtongiantButton覆盖,当我点按smallButton时,其IBAction将不会被触发,它在故事板中链接得很好。

是因为smallButton涵盖了giantButton,还是其他什么?

2 个答案:

答案 0 :(得分:0)

如果将UIView的任何实例设置为隐藏(或alpha 0),则不会阻止UI交互。

查看禁用userInteractionEnabled是否可以帮助您,或者您可以在子类中override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool并通过触摸事件...

答案 1 :(得分:0)

我看到了问题,这个giantButton包含在堆栈视图中,虽然我尝试隐藏/禁用giantButton,但这个堆栈视图仍然阻止了我的交互。

我根据@ der_michael的建议禁用了堆栈视图的用户交互,现在它可以工作了。