我有一个带有标签的文本字段。以下循环创建 20 个文本字段。
txt_Pos_Y =20;
for (j=0; j<20; j++) {
if (j<20) {
txtField = [[UITextField alloc] initWithFrame:CGRectMake(110, txt_Pos_Y, 100, 15)];
txtField.borderStyle = UITextBorderStyleRoundedRect;
txtField.font = [UIFont systemFontOfSize:11];
txtField.tag = j;
txtField.placeholder = @"Enter Value";
txtField.autocorrectionType = UITextAutocorrectionTypeNo;
txtField.keyboardType = UIKeyboardTypeDefault;
txtField.returnKeyType = UIReturnKeyDone;
txtField.clearButtonMode = UITextFieldViewModeWhileEditing;
txtField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
txtField.delegate = self;
[scrollView addSubview:txtField];
[txtField release];
}
}
-(void)CalculateMethod{
txtField.tag = 1;
double a;
a = Var_sqFt * Var_sqMtr;
txtField.text = [[NSString alloc] initWithFormat:@"%.4f",a];
}
在 CalculateMethod() 我想在 txtField.text 中显示“a”的值,但我无法在 txtField.tag = 1 上打印该值;
该值显示在底部 textfeild 表示 txtField.tag =19;
我想在 txtField.tag = 1 文本字段上显示“a”的值。
像这样
txtField.tag = 1 txtField.text.tag = [[NSString alloc] initWithFormat:@"%.4f",a];
这该怎么做?