如何以编程方式触发UIButton

时间:2014-10-24 10:49:49

标签: swift

我想在另一种方法中触发IBAction方法

按钮的IBOutlet为currentButton

我想触发triggerTheButton方法

中的按钮

怎么做?

我不知道要调用什么动作,我应该有什么参数

func  triggerTheButton()->Void{

}

@IBOutlet var currentButton: UIButton!

self.currentButton.sendAction(<#action: Selector#>, to: <#AnyObject?#>, forEvent: <#UIEvent?#>)

@IBAction func showPrevious(sender: UIButton) {

}

1 个答案:

答案 0 :(得分:0)

只有触摸事件才能触发导致以这种方式处理动作的链。您只能通过使用非公共API来实现此目的,这将导致从AppStore拒绝您的应用程序。如果您仍然对该主题感兴趣,我建议您分析UI automatic tests framework on Github的来源。