ios - collectionview are repeating inside a tableview cell -


i using collectionview inside tablview cell, in collectionview cells having imageview on images displaying array of urls in cellforitematindexpath. calling webservice inside tableview cell class getting array of urls. problem whenever scrolls down or tableview, collectionview cells repeating, images of collectionview repeating itself. how rid out of this.

my code follows -

inside response of webservice

let imglist : nsarray = arrreponsedetails.value(forkey: "imagelist") as! nsarray         self.arrimgurls.removeall()         dict in imglist[0] as! nsarray {             let dictionary = dict as! nsdictionary             let strurl : string = dictionary["url_highres"] as! string             let url : url = url(string: strurl)!             self.arrimgurls.append(url)         }         self.collectionview.reloaddata() 

code inside of cellforitematindexpath

let cell : collectioncell =  collectionview.dequeuereusablecell(withreuseidentifier: "collectioncell", for: indexpath) as! collectioncell  let url : url = self.arrimgurls[indexpath.row] cell.imgsticker.sd_setshowactivityindicatorview(true) cell.imgsticker.sd_setindicatorstyle(.gray) cell.imgsticker.sd_setimage(with: url, placeholderimage: nil) cell.imgsticker.contentmode = .scaleaspectfit return cell 

i not getting insight question think problem caching of image reusable cell.

simply implement prepareforreuse() method in collectionview cell class(collectioncell).

override func prepareforreuse() {     super.prepareforreuse()     self.imgsticker = nil } 

reference of prepareforreuse()


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -