在 iOS 中将用户操作发送到父 uiview

Send user action to parent uiview in iOS

我正在研究不同 uiview 中的用户交互。

我知道如何在父视图或其特定 UI 组件上发送用户交互。

在我的示例中,我正在向 UIButton 发送事件,即使我在 UIButton 边界之外点击也能正常工作(请查看附加代码以了解更多内部信息)。

但我不知道当我点击顶部视图时,UIButton TouchDown 选择器被调用但 TouchUpInside 没有调用。为什么会这样?

有什么建议吗?非常感谢任何解释!

Github代码link:https://github.com/jackMac1811/iOSUIInteractionTest

所有 uibutton 事件都有自己的行为,可以根据它执行它的代码。

if you want to invoke both methods tapping on top view you should have to use touch up outside instead of touch up inside event Here's a very useful link

希望这对您有所帮助..