views:

85

answers:

1

I have about 10 UIButtons on xib file and want to setText programatically

+1  A: 

You might want to be more specific next time you ask a question.

You can try assign a different tag for each button in interface builder (or the same tag if thats what you need) and then use the following code

for (int i = 1 ; i<=10;i++)
{
     UIButton *myButton = (UIButton *)[myView viewWithTag:i];
     [myButton setTitle:@"my text" forState:UIControlStateNormal];
}
Ron Srebro
This is exactly what i am looking for... one question myview would be instance of xib file?
I assume your NIB is for a UIViewController, so if this code is inside the UIViewController code myView should be view
Ron Srebro
or more precisely, myView must be the parent view of your buttons
Vladimir
Anybody have thoughts on whether it's better to do this or just make some instance variables with IBOutlets from IB?
bjtitus
It really depends what are you after. If all the buttons have different names and functions, then IBOutlets might be the right way to go.
Ron Srebro