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
2010-07-28 11:05:35
This is exactly what i am looking for... one question myview would be instance of xib file?
2010-07-28 11:13:37
I assume your NIB is for a UIViewController, so if this code is inside the UIViewController code myView should be view
Ron Srebro
2010-07-28 11:15:10
or more precisely, myView must be the parent view of your buttons
Vladimir
2010-07-28 11:17:47
Anybody have thoughts on whether it's better to do this or just make some instance variables with IBOutlets from IB?
bjtitus
2010-07-28 13:09:44
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
2010-07-31 16:11:39