iテーブルビューがあり、これにカスタムセルを使用します。今私はバーに明確なボタンを設定しています。その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
}
}
ここで、セルには、UITextFieldとしてtxtAnswerが含まれています。どのように私はtxtAnswerのテキストフィールドをクリアすることができます。フィールドをクリアするための
:
func clearView(sender:UIButton)
{
print("Clear Button clicked")
}
「クリア」ボタンを押した後、「データソース」のデータはどうしますか?データを保持し、ラベルを消去したいですか? – Eendje
UITextフィールドをクリアしてください – Sam
質問は 'lblQuestion'ではなく' txtAnswer'を求めています。なぜ以下の答えが 'lblQuestion'を参照しているのですか? – chengsam