views:

40

answers:

1

How would I go about having a list of labels, and when a Round Rectangular Button is pushed the UILabel above it changes to a label off the list randomly.

A: 

Assuming you've already setup your labels and defined an index to the current label in your interface, you could do something like this:

NSArray *labels = [NSArray arrayWithObjects:label1, label2, label3, nil];
int currentLabel = 0;

-(void)onButtonPress:(id)sender {
    [[labels objectAtIndex:currentLabel++] removeFromSuperview];
    if (currentLabel == [labels count])
        currentLabel = 0;
    [self addSubview:[labels objectAtIndex:currentLabel]];
}
Nick Bedford