Programmatically fire button click event?

Getsy picture Getsy · Apr 11, 2011 · Viewed 98.4k times · Source

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.

Thanks.

Answer

Zaky German picture Zaky German · Apr 11, 2011

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];