【发布时间】:2017-08-08 11:34:40
【问题描述】:
我在初始视图控制器中有几个按钮。单击任何按钮时将出现一个带有可扩展表格视图的弹出窗口。我正在对所有具有不同数据的按钮使用单个弹出框来显示在 tableview 上。当我单击第一个按钮时,弹出窗口中的选定项目正在被删除,当我单击其他按钮时,所有这些都将被删除。所选项目将保存到基于 indexpath.row 的数组中。当我尝试从基于相同 indexpath.row 的同一数组中删除所选项目时,出现异常错误。
如何为所有弹出框存储每个单元格选择的复选标记?
这是我的一段代码
func expandableTableView(_ expandableTableView: LUExpandableTableView, didSelectRowAt indexPath: IndexPath)
{
let selectedService = arrData[indexPath.section].Children?[indexPath.row].EnglishName ?? ""
let inPrice = arrData[indexPath.section].Children?[indexPath.row].InPrice ?? 0
print("service and price : \(selectedService) \(inPrice)")
let selectedItem = (" \(selectedService) \(inPrice)")
let cell: UITableViewCell? = expandableTableView.cellForRow(at: indexPath)
if cell?.accessoryType == UITableViewCellAccessoryType.none
{
cell?.accessoryType = UITableViewCellAccessoryType.checkmark
selectionArr.append(selectedItem)
inPriceCount = inPrice
}
else
{
cell?.accessoryType = UITableViewCellAccessoryType.none
selectionArr.remove(at: indexPath.row)
inPriceCount = -inPrice
}
self.delegate?.messageData(data: selectionArr as AnyObject)
self.delegate?.inPrice(data: inPriceCount as AnyObject)
let rowToSelect = [expandableTableView .indexPathForSelectedRow]
print(rowToSelect)
}
【问题讨论】:
标签: ios uitableview swift3 nsuserdefaults