ios - Selecting a row in table view with image and label gives only label text when get selected -
i have made program can select 2 things image
, label
table view , printed in console. when run program table view appears , cell contains image
, label
when select specific cell, text selected , image disappears. while when run program continuously gives memory warnings well.
func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) { let selecteddatag = countryl[indexpath.row] countrybutton.settitle(selecteddatag, for: .normal) self.countrytable.ishidden = true self.flag = 1 let indexpath = countryt.indexpathforselectedrow let currentcell = countryt.cellforrow(at: indexpath!)! as! flagtableviewcell let finalresult = currentcell.countrylabel.text! let finalflag = currentcell.flagimage.image! print("\(finalflag)" + "\(finalresult)") } }
it's quirk of uitableviewcell, can use:
cell.selectionstyle = .none
to prevent happening , stop grey highlight when cell selected, can put custom selection code within override func setselected(_ selected: bool, animated: bool) {}
as memory warning unrelated , should looked into.
Comments
Post a Comment