我在应用程序中创建了一个动态按钮,并调用以下方法:
[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/