0

这个问题与我之前提出的题为“从循环中识别 UIButton ”的问题有点相关。

在这种情况下,我生成了一堆带有循环的 UITextField。当其中一个的值发生更改时,我能够识别它是哪个文本字段。

但是,我想编辑生成的每个文本字段。具体来说,我从一个已编辑的文本字段中获取输入,并且我想根据已识别文本字段的输入和名称重新计算其他文本字段。

我如何要求修改每个其他生成的、未编辑的文本字段?

/弗拉德

4

2 回答 2

0

将文本字段存储在数组中,然后当您想要更改值时

[self.myTextFieldArray enumerateObjectsUsingBlock:^(UITextField *textField, NSUInteger idx, BOOL *stop){
    if (![textField isEqual:theTextFieldThatWasEdited])
        textField.text = @"whatever text you want";
}];
于 2012-05-26T18:46:25.857 回答
0

由于您已经在使用标签,因此这viewWithTag是用于:

// Get a reference to the textfield with tag 3
UITextField *textField3 = (UITextField *)[self.view viewWithTag:3];

// Calculate your new value
float result = 4.32; // Calculate the value that you want the textfield with tag 3 to display

// Change the contents
textField3.text = [NSString stringWithFormat:@"%f", result];
于 2012-05-26T19:34:03.650 回答