gpt4 book ai didi

iPhone UIControl 和 subview

转载 作者:行者123 更新时间:2023-12-03 19:02:53 25 4
gpt4 key购买 nike

我目前有一个 UIControl,它有许多 subview (图像、标签)。

不幸的是,当我使用 addTarget 等时,它不会检测到 subview 上的触摸。

  [myCustomView addTarget:self action:@selector(touchedView:)
forControlEvents:UIControlEventTouchUpInside];

UIControl 是否可以检测 subview 上的触摸,或者我应该以不同的方式处理它。

最佳答案

请注意,UIControl 的所有 subview 本身不应接收触摸事件,必须将 userInteractionEnabled 设置为 NO 而不是 YES(默认设置)。

因此您必须在所有标签、图像等上设置此项。

我刚刚遇到这个问题并在一段时间后解决了:)

关于iPhone UIControl 和 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2778685/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com