gpt4 book ai didi

iphone - 带子项的 UIView 上的 TouchUpInside

转载 作者:行者123 更新时间:2023-12-03 18:19:40 26 4
gpt4 key购买 nike

我可能在这里遗漏了一些东西,但是......

我有一个 UIView 和几个 child (几个 UILabelUIImageView)。当用户单击(点击)父 UIView 中的任何位置(UIView 或其任何子级的可见部分)时,我需要捕获事件。

最好的方法是什么?

最佳答案

您可以在身份检查器中更改 UIView 的类...使其成为 UIControl,然后您可以为您的 View 添加 UITouchUpInside 事件 - 以捕获点击就在上面。

祝你好运!

编辑:这是带有屏幕截图的分步说明:

景色... Original view - of type UIView

...当然,没有事件。 UIView has no events you can use

返回并使用 UIControl 更改 UIView 并... Change UIView to UIControl

哒哒!事件! UIControl allows you to use events

将方法 Hook 到 UITouchUpInside 事件 Add event for UITouchUpInside

这就是接口(interface)文件中的样子 The interface of the method

这就是实现文件中的样子(当然,您可以将日志记录替换为您想要的任何内容) The implementation of the method

关于iphone - 带子项的 UIView 上的 TouchUpInside,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10728830/

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