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

标签 iphone ios cocoa-touch

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

[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/

相关文章:

iOS使用socket连接发送数据

iphone - 我可以删除 App Store 上已有应用的分发配置文件吗?

iphone - UISegmentedControl 和添加目标

ios - JSON 字符串编码 - 混淆

iphone - 改变放大镜的颜色

ios - 使用 vImageHistogramCalculation 计算图像的直方图

ios - 如何在 UICollectionView 和 UIView 之间创建空白?

ios - SimplePCMRecorder 中的 AudioQueueBufferRef 在 swift 3 中显示错误

ios - searchBarCancelButtonClicked popToRootViewControllerAnimated

ios - 如何暂停 dispatch_queue_t 及其创建的队列