make static buttons dynamic
I have added 10 custom buttons using interface on view. Now I want to make visible that no of buttons only whenever user put value. e.g If user put 5 then on button click 5 buttons get visible. Can it 开发者_如何学Gobe possible? If anyone know please give me the solution.
Thanks alot.
Set Tag for each button in xib. Compare the tag value & show the button.
set tag in increasing order lets say 100+buttonNumber (100,101,102...110).
Now for user's input you would have a UITextField(lets say mtTextField) and a button (lets say "Show") to see the effect.so do following in the tuchUpInside method of Show button
int i = [myTextField intValue];
UIButton* btn;
for(int j = 1; j<=i;j++)
{
btn = (UIButton*)[self.view viewWithTag:100+j];
[btn setHidden:NO];
}
精彩评论