swift - How to to hide switch from cell? -
how hide switch cell when barbutton title edit change done how possible?
override func setediting(_ editing: bool, animated: bool) { super.setediting(editing,animated:animated) if self.isediting{ self.editbuttonitem.title = "done" tableview.setediting(true, animated: true) tableview.reloaddata() } else{ self.editbuttonitem.title = "edit" tableview.setediting(false, animated: false) } }
in setediting method can access visible rows way
tableview.visiblecells.foreach{ cell in //define custom cell class if let customcell = cell as? yourcustomcellcalss{ //call here method show/hide switch or whatever have hiding customcell.hideswitch() } }
but change visible rows, need add checking self.isediting in cellforrowat method rows dequeued after scrolling show/hide switch
if code differs custom cell implementation, please add more of code in question
let me know if you'll need
Comments
Post a Comment