私はこのようなものを作ってみました:
for (int i=0; i<8; i++) {
UIButton *btn_i = [[UIButton alloc] initWithFrame:CGRectMake(0 * numberRowsOfMenu, 0 * heightOfRow, btnWidth, btnHeight)];
}
ここでUIButton *btn_i
はbtn_
+ の値ですi
。
Obj-Cで可能ですか?
私はこのようなものを作ってみました:
for (int i=0; i<8; i++) {
UIButton *btn_i = [[UIButton alloc] initWithFrame:CGRectMake(0 * numberRowsOfMenu, 0 * heightOfRow, btnWidth, btnHeight)];
}
ここでUIButton *btn_i
はbtn_
+ の値ですi
。
Obj-Cで可能ですか?
btn_0、btn_1 などの名前の変数を使用したいということですか?
いいえ、できません。次のような方が良いかもしれません:
NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:8];
for(int i=0; i<8; i++) {
UIButton *b = [[UIButton alloc] initWithFrame:...];
[butttons addObject:b];
[b release];
}
// Now you can access the buttons array with indices, e.g:
UIButton *b = [buttons objectAtIndex:4];