Thursday, September 26, 2013

About the problem of dynamically generated button

UIButton * button1 = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button1.frame = CGRectMake (100 + tag +20, 80, 100, 60);
[Self.OneGroupUnitView addSubview: button1];

I have a separate button to add to a view is not wrong
The problem is I am going to be in a loop to dynamically generate lots of button
If so, then I'm the definition of each one? Button1 name is not the same what, so in the end only one?
Neighborhoods Great God, how to solve this problem?
Reply:
Access points.
The
{
UIButton * button1 = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button1.frame = CGRectMake (100 + tag +20, 80, 100, 60);
[Self.OneGroupUnitView addSubview: button1];
}
This code is placed inside the loop body.

No comments:

Post a Comment