本文介绍了以编程方式触发按钮点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法以编程方式触发按钮点击事件?我在UIView中放置了一个按钮,在特定情况下,我想通过代码单击按钮,而不是手动作为用户。 iOS开发有可能吗?请提供您的建议并指导我如何做。
Is there a way to programmatically fire a button click event? I have a button placed there in an UIView, and in a particular scenario i want to click the button via code, not manually as a user. Is it possible in iOS development? Please provide your suggestions and guide me how to do that.
谢谢。
推荐答案
有点像Ken的回答,但更灵活,因为如果你更改或添加多个按钮,它会跟踪按钮的实际操作。
Sort of like Ken's answer, but more flexible as it'll keep track of the buttons actual actions if you change them or add more than one.
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
这篇关于以编程方式触发按钮点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!