ios - Slow Tableview with custom cell with images, Swift 3 and core data -
i trying solve slow, sluggish scrolling on table.
i'm using core data wrapper aerecord fetch data, , scrolls smooth without cell.toneimage.image = uiimage(named: tone.image)
the images aren't big ( 350 x 170) def freezes second scroll enough load new image.
i checked blended images in simulator, etc.. data being fetched + loading image @ same time? ideas or suggestions?
override func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecell(withidentifier: "cell", for: indexpath) as! mwcelltableviewcell self.configurecell(cell, atindexpath: indexpath) return cell } func configurecell(_ cell: mwcelltableviewcell, atindexpath indexpath: indexpath) { if let frc = fetchedresultscontroller { if let tone = frc.object(at: indexpath) as? tone { // set data cell.tonetitle.text = tone.name.uppercased() let img:uiimage = tone.fav ? #imageliteral(resourcename: "likebtnon") : #imageliteral(resourcename: "likebtnoff") cell.favbutton.setimage(img, for: .normal) cell.favbutton.tag = indexpath.row cell.favbutton.addtarget(self, action: #selector(favme(_:)), for: .touchupinside) cell.toneimage.image = uiimage(named: tone.image) cell.toneimage.layer.cornerradius = 8.0 cell.toneimage.clipstobounds = true } } }
there 2 way solve this
fetch , set image in background using async.
fetch image before reloading tableview data
Comments
Post a Comment