Cocoa touch 如何在iOS系列中动态创建标签

Cocoa touch 如何在iOS系列中动态创建标签,cocoa-touch,Cocoa Touch,这就是问题所在,我想在xCode中绘制一个dinamic屏幕,这取决于从Web服务器提交的标签数量,是这样的 for (int i = 0; i< [webserver.arraylabels count]; i++){ UILabel *label[i]; label[i] = [functions createLabel:[[webserver.arraylabels objectAtIndex:i] textLabel]

这就是问题所在,我想在xCode中绘制一个dinamic屏幕,这取决于从Web服务器提交的标签数量,是这样的

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]];
}
for(int i=0;i<[webserver.arraylabels count];i++){
UILabel*标签[i];
label[i]=[functions createLabel:[[webserver.arraylabels objectAtIndex:i]textLabel]
locationX:[webserver.arraylabels objectAtIndex:i]locationX]
locationY:[webserver.arraylabels objectAtIndex:i]locationY]
高度控制:[webserver.arraylabels objectAtIndex:i]高度控制]
宽度控制:[webserver.arraylabels objectAtIndex:i]宽度控制]
调整控制:UIViewAutoResisingFlexiblerRightMargin];
[单元格添加子视图:标签[i]];
}
[functions createLabel…]是一个返回UILabel对象类型的函数

如果我运行此操作,会因为标签名称上的[I]而出现错误,我该如何执行此操作


提前感谢您的支持

这是感谢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];
}


你为什么需要它?只需使用
UILabel*label=[functions createLabel]…因为我想把它们放在几个位置或表格单元格上,就像一个公式集一样,我也在考虑添加文本字段,并为它们设置长度,类似于键盘,为它们分配事件,但为此我需要它们有一个不同的名称,如textField1、textField2、textField3。。。。label1,label2,Label3不需要“不同的名称”。一个原始的C数组很好(只需在循环之外声明它),一个
NSMutableArray
会更好。我想这就是你的意思,不是吗???(第二个答案)你觉得第一个答案怎么样
UILabel *label = [arregloControles objectAtIndex:0]; //no casting required
UILabel *label = (UILabel*)[self.view viewWithTag: labelTag];