gpt4 book ai didi

iphone - iOS 主视图正在响应 subview 手势

转载 作者:行者123 更新时间:2023-11-28 22:46:04 24 4
gpt4 key购买 nike

我正在使用点击手势添加 subview :

来自 UIView 类(masterButton):

[self addSubview:self.button];

// Add gesture recognizers
[self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(isTapped:)]];

View Controller :

masterButton *button = [[masterButton alloc] initWithFrontImage:img ];

[self.view addSubview:button];

我删除 subview :

UIView * button= [controller.view viewWithTag:controller.tagButton]; [button removeFromSuperview];

它触发播放音频文件的点击手势并且工作得很好,但是当我删除 subview 并点击 subview 所在的相同区域时,它会播放音频,就像 subview 在那里一样。如果主视图不响应 subview 的任何手势,我该如何添加 subview ?

我正在从 UIview 子类生成 subview ,如果我尝试添加这样的手势:

[self.button addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(isTapped:)]];

这是行不通的。你们有人知道为什么吗?

非常感谢您的帮助。

最佳答案

添加按钮喜欢

[self.button addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(isTapped:)]]

[self.button removeFromSuperview];

关于iphone - iOS 主视图正在响应 subview 手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13189120/

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