我有一个在附件视图位置有名称和文本字段的表格视图。使用以下 UITableViewDelegate 方法,我正在调用 onEdit,它调用 UIPickerView。问题是,如果我有超过 1 个单元格,它只会填充最后一个 uitextfield 中的数据,无论我点击哪个文本字段。如何允许数据进入我正在编辑的文本字段?
def tableView(tableView, cellForRowAtIndexPath: indexPath)
@reuseIdentifier ||= "CELL_IDENTIFIER"
cell = tableView.dequeueReusableCellWithIdentifier(@reuseIdentifier) || begin
UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier:@reuseIdentifier)
end
picker = UIPickerView.alloc.initWithFrame([[0, self.view.frame.size.height / 2 + 50], [self.view.frame.size.width, self.view.frame.size.height]])
picker.delegate = self
picker.showsSelectionIndicator = true
@picker_field = UITextField.alloc.initWithFrame([[200,20],[150,40]])
@picker_field.placeholder = "Choose Location.."
@picker_field.delegate = self
@picker_field.inputView = picker
cell.textLabel.text = @list[indexPath.row]
cell.accessoryView = @picker_field
cell.selectedBackgroundView.backgroundColor = UIColor.redColor
#cell.selectionStyle = UITableViewCellSelectionStyleNone
cell
end
def pickerView(pickerView, numberOfRowsInComponent: component)
@choices_count
end
def pickerView(pickerView, titleForRow: row, forComponent: component)
@choices[row]
end
def pickerView(pickerView, didSelectRow: row, inComponent: component)
@picker_field.text = @choices[row]
@picker_field.resignFirstResponder
end