title: Is there a way to programmatically "tap" UIControls such as segment buttons?
body: <p>I hope that the answer to my question may be useful to a lot of developers and fear that it is a really stupid question: I have a routine that graphically and programmatically shuffle cards in 5 different ways (including cut and deal.) This is implemented from a UISegmentControl, replacing a 5-button Modal Alert. This all works very well but here is the problem: When it is the computer's turn to deal I built a for-loop inside a for-loop to trigger random number generated calls to the shuffling graphic routines a random number of times &lt; 10.  All of the calls seem to be executed for the entire for-loops sets before any graphics show up on the screen. Then I see face-down and face up cards moving all over the screen. Psychedelic, right? It seems that my control loop logic is executing without blocking or waiting or serializing the graphics. Remember that the graphics work fine when the user is tapping one segment at a time. I have been considering implementing a UITouchEvent to programmatically simulate tapping the buttons but I haven't found a single example. Is it possible to programmatically "tap" the segment "buttons"? </p>