我开始了我的 ios 开发,一开始我认为制作一个度量转换器会很有趣。
我设法用故事板创建了带有segues的表格视图,带有文本字段的自定义单元格和对应于不同尺寸的标签,但现在我卡住了,无法在我正在阅读的教程或书中找到答案。
在每个单元格中都有一个对应于给定尺寸(即米、厘米等)的文本字段。如何获取给定行中的文本字段已完成编辑的事件,并在计算后更改其他文本字段?(单元格是从包含计算所需的维度名称和值的数组创建的)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UILabel *label;
UITextField *field;
static NSString *CellIdentifier = @"DimensionCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
label = (UILabel *)[cell viewWithTag:1];
field = (UITextField *)[cell viewWithTag:2];
field.delegate = self;
NSString *DimensionLabel = [self.dimension objectAtIndex:indexPath.row];
label.text = DimensionLabel;
return cell;
}