我有一个表格视图并为此使用自定义单元格。现在我在我的酒吧里设置了一个清晰的按钮。现在单击该UIBarButton,我想清除单元格中文本字段内的所有文本。我怎样才能做到这一点..??删除表格视图单元格中的UIlabel文本
var DataSource = [NewAssessmentModel]()
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.DataSource.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let model = self.DataSource[indexPath.row]
switch(model.assessmentControlType)
{
case .text:
let cell = (tableView.dequeueReusableCellWithIdentifier("QuestionWithTextField", forIndexPath: indexPath) as? QuestionWithTextField)!
cell.model = model
cell.indexPath = indexPath
cell.txtAnswer.delegate = self
cell.lblQuestion.text = model.labelText
cell.indexPath = indexPath
return cell
}
}
现在单元格包含一个txtAnswer作为UITextField。我如何清除txtAnswer的文本字段。
清除字段:
func clearView(sender:UIButton)
{
print("Clear Button clicked")
}
按下“清除”按钮后,你想要在'dataSource'中的数据发生什么?你想保留数据,只是清除标签? – Eendje
清除UIText字段 – Sam
问题是要求'txtAnswer',而不是'lblQuestion'。为什么下面的答案是指'lblQuestion'? – chengsam