UI 元素点击没反应

1: View [ CollectionView ] 的点击事件

如果View添加了 Gesture, 要想 CollectionView 的Cell的点击事件被处理,需要设置 gesture.cancelsTouchesInView = false

open var cancelsTouchesInView: Bool 
// default is YES. causes touchesCancelled:withEvent: or pressesCancelled:withEvent: to be sent to the view for all touches or presses recognized as part of this gesture immediately before the action method is called.

2: View1 [ View2 ] 的点击事件

View1 包含 View2,但是View2的点击事件就是没有处理(不管把View2 设置为 UIButton 或者 UIImageView 都不行),最后是 [Debug View Hierarchy]才发现 View2 不在 View1 的 frame 内。所以事件没有传递。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容