gpt4 book ai didi

iphone - 在 UIButton 上使用两个不同的控制事件

转载 作者:行者123 更新时间:2023-11-29 04:44:37 25 4
gpt4 key购买 nike

我在应用程序中创建了一个动态按钮,并调用以下方法:

[btnactions addTarget:self 
action:@selector(deleteview:)
forControlEvents:UIControlEventTouchDown];</b>

这个deleteview方法用于每当我单击按钮时删除特定的应用程序 View 。

现在,我想要另一种方法来动态调用按钮事件

UIControlEventTouchDownRepeat

那么如何使用不同的控件事件调用两个不同的事件?

最佳答案

您可以使用 UIControlEventTouchDownRepeat 再次调用 addTarget

来自文档(UIButton 继承自 UIControl ):

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents

You may call this method multiple times, and you may specify multiple target-action pairs for a particular event. The action message may optionally include the sender and the event as parameters, in that order.

关于iphone - 在 UIButton 上使用两个不同的控制事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9821742/

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