charmingduck
asked on
for loop in objective c
how do I output this in using a for loop in objective c?
[self.window addSubview:button];
[self.window addSubview:button2];
[self.window addSubview:button3];
[self.window addSubview:button4];
[self.window addSubview:button5];
[self.window addSubview:button6];
[self.window addSubview:button7];
[self.window addSubview:button8];
[self.window addSubview:button9];
[self.window addSubview:button10];
[self.window addSubview:button];
[self.window addSubview:button2];
[self.window addSubview:button3];
[self.window addSubview:button4];
[self.window addSubview:button5];
[self.window addSubview:button6];
[self.window addSubview:button7];
[self.window addSubview:button8];
[self.window addSubview:button9];
[self.window addSubview:button10];
If you need prompt answers you might consider increasing the points to 500 on your questions, although your questions are not difficult but the explanation is somehow difficult since it sounds you are just beginning iOS development.
ASKER
400 is sufficient, please help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
and how do I not create 10 buttons manually?
Then you may try this:
for (int i =0; i != 0; i++) {
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(20, 20 + i*25, 100, 20); // position in the parent view and set the size of the button
[myButton setTitle:@"Click Me!" forState:UIControlStateNormal];
[self.window addSubview:myButton];
}
ASKER
hmm, I dont think this code works, and I did try, it didn't.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.