tags:

views:

131

answers:

2

Hi All,

I need to set the labels of the UI dyanmically.. I want be read the text from an xml file and would like to set the text to the controls in the NIB.

I guess i can recognise the conrol by using the TAG attribute of the control.

Now i would like to get all the objects in the window(controls in the Nib) into an array?

Please suggest me on this.

+2  A: 

In your code you'll want to create a link to your control. In xcode, in your .h file put something like:

@interface Mycontroller : UIViewController {
 IBOutlet UILabel *namelabel;
}

@property (nonatomic, retain) IBOutlet UILabel *namelabel;

-(void)ChangeName:(NSString *)toName;

@end

Then in your .m file put something like:

@implementation ProjectCell
@synthesize namelabel;


-(void)ChangeName:(NSString *)toName {
 [namelabel setText:@"your new string"];
}

You then want to open your nib in interface builder. Select your label and go to the inspector (Tool Menu > Inspector). Go to the Connections tab (blue circle w/ white arrow, and then click and drag the circle by New References Outlet from there to File's Owner in the nib window. Select "namelabel" from the popup. They're now linked and changing namelabel in code will change that specific label that you setup in interface builder.

mjdth
hey i do not want to do in this way...i want to do something like running a loop with an array of the control objects and set the titles or labels of the UI.So for that i want to get all the object into an naarray
Pradeep Kumar
A: 

I agree with the above soultion....

I had to set the title of each textfield and buttons in applicationdidFinishLaunching function.

Pradeep Kumar