gpt4 book ai didi

ios - 想要按钮吞下所有的触摸

转载 作者:行者123 更新时间:2023-11-28 08:39:28 25 4
gpt4 key购买 nike

我正在尝试建立自己的下拉列表。我通过创建 UIButton 的子类创建了一个自定义 View 。第一次单击按钮时将显示列表。现在我希望下次当它单击该按钮和列表之外的任何地方时,应该通知此类。或者换句话说,我想让这个按钮吞下所有的触摸。我怎样才能做到这一点?

最佳答案

使用 touchesBegan 方法。

例如:

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{

UITouch *touch = [touches anyObject];

if([touch View] != yourbutton)
{

//do what u want to do
}
}

关于ios - 想要按钮吞下所有的触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36764018/

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