我有包含多行的 TableView,当我取消选择任何行时,我正在选择它们并将它们添加到标签文本中我无法从标签文本中删除它
这是我的代码:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if tableView == categoryTable
{
let cell = self.categoryTable.dequeueReusableCellWithIdentifier("categoryCell") as! InquiryCategoryTableViewCell
let Category:CategoryDB = categoryData.objectAtIndex(indexPath.row) as! CategoryDB
print("Category = \(Category.category)")
cell.categoryName.text = "\(Category.category)"
cell.tintColor = color.UIColorFromRGB(0xCEEBFF)
categoryTable.allowsMultipleSelectionDuringEditing = true
categoryTable.setEditing(true, animated: false)
return cell
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if tableView == categoryTable
{
categoryList = categoryData[indexPath.row] as! CategoryDB
self.category_id = categoryList!.catg_id
print("Name = \(categoryList!.category)")
print("ID = \(self.category_id)")
categoryLabel.text! += "\(categoryList!.category), "
}
}
这是我得到的输出:
我首先选择了 3 行,它被附加到Label.text,在我取消选择行后,Label.text保持不变
谁能在这段代码中帮助我?