views:

70

answers:

1

I want to use two labels on the same view in an iPod Touch application. I have created the two labels, but I only know how to access on of them. Does any one have an example of how to do this?

A: 
UILabel *label1 = [[UILabel alloc] initwithFrame: CGRectMake(0,0,100,100)];
UILabel *label2 = [[UILabel alloc] initwithFrame: CGRectMake(0,0,200,200)];

label1.text = @"Label One";
label2.text = @"Label Two";

Or, if you created your labels in Interface builder, make sure you've got IBOutlets for both of them in order to access them from your code.

luvieere
Is the default name label as in label.text ?
kman99
I'm not sure what you mean by default name. The idea is to have control over variable names, not rely on defaults, in fact, you must know what IBOutlet you link your IB labels to.
luvieere