0

それが問題です。webServer からのラベルの量に応じて、xCode で動的な画面を描画したいのですが、そのようなものです...

for (int i = 0; i< [webserver.arraylabels count]; i++){
   UILabel *label[i];
   label[i] = [functions createLabel:[[webserver.arraylabels objectAtIndex:i] textLabel]
                                                   locationX:[webserver.arraylabels objectAtIndex:i] locationX]
                                                   locationY:[webserver.arraylabels objectAtIndex:i] locationY]
                                                 heightControl:[webserver.arraylabels objectAtIndex:i] heightControl]
                                                  widthControl:[webserver.arraylabels objectAtIndex:i] widthControl]
                                                adjustmentControl:UIViewAutoresizingFlexibleRightMargin];

[cell addSubview:label[i]];
}

[functions createLabel...] は、UILabel オブジェクト タイプを返す関数です...

これを実行すると、ラベル名の [i] が原因でエラーが発生します。どうすればよいですか??

ご支援いただきありがとうございます

4

1 に答える 1

0

これがH2CO3のおかげで答えです

NSMutableArray *arregloControles = [[NSMutableArray alloc]init];

for (int i = 0; i< [webserver.arraylabels count]; i++){
   UILabel *control;
   control = [functions createLabel:[[webserver.arraylabels objectAtIndex:i] textLabel]
                                                   locationX:[webserver.arraylabels objectAtIndex:i] locationX]
                                                   locationY:[webserver.arraylabels objectAtIndex:i] locationY]
                                                 heightControl:[webserver.arraylabels objectAtIndex:i] heightControl]
                                                  widthControl:[webserver.arraylabels objectAtIndex:i] widthControl]
                                                adjustmentControl:UIViewAutoresizingFlexibleRightMargin];

[cell addSubview:control];

[arregloControles addObject:control];
}

H2CO3 を呼び戻すには、次のように提案します。

UILabel *label = [arregloControles objectAtIndex:0]; //no casting required

また

UILabel *label = (UILabel*)[self.view viewWithTag: labelTag];
于 2013-08-14T00:22:25.443 に答える