2017-08-08 59 views
1

我在初始視圖控制器中有幾個按鈕。點擊任何按鈕時將出現一個帶有可擴展桌面視圖的彈出窗口。我正在使用單個彈出式窗口來顯示所有具有不同數據的按鈕。我點擊第一個按鈕時彈出窗口中的所選項目將被刪除,當我點擊其他按鈕時,所有項目都將被刪除。所選項目將根據indexpath.row保存到數組中。我試圖從基於相同的indexpath.row的相同數組中刪除選定的項目時出現異常錯誤。如何在popover中存儲tableview單元格checkmark狀態?

我該如何在所有彈出窗口的每個單元格選區上存儲複選標記?

以下是一段我的代碼

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) 

} 

回答

0

不應從數組中刪除的任何東西。只需添加一個鍵上的每個指標

dict["ischeckMarked"]=false 

當您更改對號變化自來水真的

dict["ischeckMarked"]=true 

如果已經檢查,現在要取消將其更改爲false

dict["ischeckMarked"]=false 

希望這會幫助你。

相關問題