views:

84

answers:

2

I add 10 buttons to UIScrollView

for (int i=0; i<10; i++) {

     UIButton *btn =  ....  

     [ScrollView addSubview:btn];

}

How can i refer to each button ?

+5  A: 
btn.tag = i;

and later,

[scrollView viewWithTag: 2];
David Dunham
Thank you very much.
aon
A: 

Either set the tag on each view, and find them using viewWithTag, or save references to each in an NSMutableArray or other data structure.

Mark Bessey