views:

865

answers:

2

Hi,

Is it possible to press a button in iPhone SDK programatically without the user touching it?

Thanks.

+4  A: 

Do you want the user to see the button as pressed? Set the highlighted property to true and it will look like being pressed.

Now, if you just want to simulate the consequence of a button being pressed, just call the selector you assigned to the "Touch Up Inside" or "Touch Down Inside" events.

Marco Mustapic
What selector is being called for camera's "capture" button?
Ilya
Ilya, you can't programmatically press the "capture" button; it's a violation of Apple's Human Interface Guidelines. The user must press the button.
Jeff Kelley
Ok, but guys that created the app "Big Camera Button" did it somehow - you can press anywhere on the screen to capture a photo. How can I achieve something similar to this?
Ilya
+2  A: 

You could synthesize a touch on the button's coordinates, and set the appropriate event here's how

luvieere