我想創建具有不同對象名稱的動態UITextField。我已經在下面顯示了用於動態創建文本字段的代碼。我怎樣才能創建每個文本字段與不同的對象名稱?如何用不同的對象名創建動態UITextField?
for (int x=0; x < 4 ; x++)
{
CGRect txtFldFrame;
if (x==0)
txtFldFrame=CGRectMake(385, 620, 278, 45);
else
txtFldFrame=CGRectMake(385, txtFldFrame.origin.y+60, 278, 45);
[self createTxtImg:txtImgFrame createTextfield:txtFldFrame];
}
在 createTextfield:(的CGRect)txtfldframe {
UITextField *txtFld1=[[UITextField alloc]init];
txtFld1.frame=txtfldframe;
[txtFld1 setTag:textChk];
txtFld1.borderStyle = UITextBorderStyleNone;
txtFld1.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
txtFld1.textAlignment=UITextAlignmentLeft;
txtFld1.textColor=[UIColor colorWithRed:17/255.0 green:61/255.0 blue:83/255.0 alpha:1];
txtFld1.font = [UIFont systemFontOfSize:22];
txtFld1.backgroundColor = [UIColor clearColor];
txtFld1.autocorrectionType = UITextAutocorrectionTypeNo;
txtFld1.returnKeyType = UIReturnKeyDone;
txtFld1.clearButtonMode = UITextFieldViewModeWhileEditing;
txtFld1.autocapitalizationType=UITextAutocapitalizationTypeNone;
txtFld1.delegate = self;
[subScrollView addSubview:txtFld1];
}
你是什麼意思是什麼呢?你能提供例子嗎? – Stunner 2012-07-24 11:14:59
你能否讓你的問題更清楚?你的意思是不同的對象名稱? – Mert 2012-07-24 11:15:20
請問您可以對給定的答案發表評論,以便我們知道,我們正在正確的軌道上? – Fab1n 2012-07-24 14:02:06