Hello I am working on feed and I am facing issues with displaying images correctly. The issue is with first two UITableViewCells
, that get displayed after tableView loads. The remaining cells load correctly. The code is mention below that I am using to display the images.
Following are some screenshots of the issue.
//Code to add Image.
//Code written in configurecell()
let imageURL = URL(string: ForFeed.image_url)
let media = UIImageView(frame: mediaView.bounds)
media.downloaded(from: imageURL!)
media.contentMode = UIViewContentMode.scaleAspectFill
media.layer.masksToBounds = true
self.mediaView.insertSubview(media, at: 0)
//Code to add Background image.
//Code written in awakefromnib()
UIGraphicsBeginImageContext(self.mediaView.frame.size)
let mediaPlaceholder = UIImage(named: "nilmedia")
mediaPlaceholder?.draw(in: self.mediaView.bounds)
if let image = UIGraphicsGetImageFromCurrentImageContext(){
UIGraphicsEndImageContext()
self.mediaView.backgroundColor = UIColor(patternImage: image)
}else{
UIGraphicsEndImageContext()
debugPrint("Image not available")
}
The result should display images properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.