ios - Removing all subviews from a UITableViewCell except imageView -


i creating custom cell , add subviews text mostly. @ first subviews not getting deleted when cell reused, text overwrite , blot bad. added loop function , solved problem except removes imageview , never gets re-added, whole tableview missing image supposed associated each cell.

the if statement didn't work, didn't explicitly use cell.addsubview() did cell labels, wondering if has it. have googled , found people saying worked them, cannot seem figure out.

why remove images, why won't come pack other subviews, , how can fix this?

i have following code:

func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     let cell = tableview.dequeuereusablecellwithidentifier("cell") as! uitableviewcell     subview in cell.subviews {           if subview as? nsobject != cell.imageview {             subview.removefromsuperview()         }     }     var statusimage = uiimage(named:imageconfigration(indexpath.row))!     cell.imageview?.image = statusimage     // ... } 

give imageview tag in storyboard or xib or programmatically using. in loop of subviews check if tag of subview equal tag imageview dont remove it.

also option solve if fits requirement hide elements added cell except imageview. faster looping in subviews , removing never know subview attached cell other added ios thats if fits req. let me know in case of concern

this how can this

cell.textlabel.hidden = yes; 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -