Skip to content

UiTableViewCellSelection seems not working for LUExpandableTableView. #25

Description

@tripathishivam35

Want to achieve something like this-
screen shot 2018-10-10 at 1 31 52 pm

I want to reload cells on cell click in order to check the box and fetch the checkbox values.
In DidSelectRowAtIndexPath i am doing like this-

    func expandableTableView(_ expandableTableView: LUExpandableTableView, didSelectRowAt indexPath: IndexPath) {
        
        print("Did select cell at section \(indexPath.section) row \(indexPath.row)")
        let cell = expandableTableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier, for: indexPath) as! FilterTableCell
        self.expandableTableView.beginUpdates()
        cell.setSelected(true, animated: true)
        self.expandableTableView.reloadRows(at: [indexPath], with: .automatic)
        self.expandableTableView.endUpdates()
    }

and Inside Cell for row at index path if i am checking if cell is selected or not. It always says not selected-

func expandableTableView(_ expandableTableView: LUExpandableTableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     guard let cell = expandableTableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) as? FilterTableCell else {
         assertionFailure("Cell shouldn't be nil")
         return UITableViewCell()            
     }        
     if cell.isSelected{
         print("selected")
     }
     else{
         print("not selected")
     }        
     cell.label.text = "\(self.FilterValueArray.object(at: indexPath.row))" + "  (" + "\(self.FilterCountArray.object(at: indexPath.row))" + ")"
     return cell
 }

BTW if i am checking like this inside CellForRowAtIndexPath() it shows cell is selected but with this i can't access my Cell properties.

   if let cell = expandableTableView.cellForRow(at: indexPath) {
           
           if cell.isSelected {
                 print("This cell is selected")
              // cell.button.setImage(UIImage(named: "CheckboxUnchecked"), for: .normal)
           }
           else{
               print("This Cell is not selected")
               // cell.button.setImage(UIImage(named: "CheckboxUnchecked"), for: .normal)
           }
       }

So could u assist me on this that how can i work out my cell selection issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions