{"action":"created","issue":{"url":"https://api.github.com/repos/onevcat/Kingfisher/issues/873","repository_url":"https://api.github.com/repos/onevcat/Kingfisher","labels_url":"https://api.github.com/repos/onevcat/Kingfisher/issues/873/labels{/name}","comments_url":"https://api.github.com/repos/onevcat/Kingfisher/issues/873/comments","events_url":"https://api.github.com/repos/onevcat/Kingfisher/issues/873/events","html_url":"https://github.com/onevcat/Kingfisher/issues/873","id":304148806,"node_id":"MDU6SXNzdWUzMDQxNDg4MDY=","number":873,"title":"Problem with Dynamic height image in tableview cell using URL Kingfisher","user":{"login":"FedericoSub","id":35109594,"node_id":"MDQ6VXNlcjM1MTA5NTk0","avatar_url":"https://avatars0.githubusercontent.com/u/35109594?v=4","gravatar_id":"","url":"https://api.github.com/users/FedericoSub","html_url":"https://github.com/FedericoSub","followers_url":"https://api.github.com/users/FedericoSub/followers","following_url":"https://api.github.com/users/FedericoSub/following{/other_user}","gists_url":"https://api.github.com/users/FedericoSub/gists{/gist_id}","starred_url":"https://api.github.com/users/FedericoSub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FedericoSub/subscriptions","organizations_url":"https://api.github.com/users/FedericoSub/orgs","repos_url":"https://api.github.com/users/FedericoSub/repos","events_url":"https://api.github.com/users/FedericoSub/events{/privacy}","received_events_url":"https://api.github.com/users/FedericoSub/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-03-11T10:59:31Z","updated_at":"2018-09-06T11:56:16Z","closed_at":null,"author_association":"NONE","body":" Check List\r\n\r\nThanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.\r\n\r\n- [x] I have read the [wiki page](https://github.com/onevcat/Kingfisher/wiki) and [cheat sheet](https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet), but there is no information I need.\r\n- [x] I have searched in [existing issues](https://github.com/onevcat/Kingfisher/issues?utf8=✓&q=is%3Aissue), but did not find a same one.\r\n- [x] I want to reoprt a problem instead of asking a question. It'd better to use [kingfisher tag in Stack Overflow](http://stackoverflow.com/questions/tagged/kingfisher) to ask a question.\r\n\r\nIssue Description\r\nProblem with Dynamic height image in cell Tableview\r\n\r\nWhat\r\nIn my app I download the image from Firebase and in TableViewCell.swift resize the image with current aspectRatio.\r\nThe first time tableView is populate correctly but sometime seems that some rows are display without the image .\r\nIf I scroll the tableview the image will be reloaded fine.\r\n\r\nIf I don't use Kingfisher but load image from array all works.\r\n\r\n\r\n\r\nReproduce\r\n\r\noverride func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\r\n        let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\") as! VetrinaTableViewCell\r\n        \r\n        let resource1 = ImageResource(downloadURL: URL.init(string: vetrina[indexPath.row].urlPhoto)!, cacheKey: vetrina[indexPath.row].urlPhoto)\r\n        let p1 = Bundle.main.path(forResource: \"loading\", ofType: \"gif\")\r\n        let data1 = try! Data(contentsOf: URL(fileURLWithPath: p1!))\r\n        cell.immagineVetrina.kf.indicatorType = .image(imageData: data1)\r\n        cell.immagineVetrina.kf.setImage(with: resource1)\r\n     \r\n        \r\n        cell.setNeedsLayout()\r\n        return cell\r\n    }\r\n\r\n\r\nIf I don't use Kingfisher works fine this is the code.\r\n\r\noverride func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\r\n        let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\") as! VetrinaTableViewCell\r\n        \r\n        cell.immagineVetrina.image = UIImage(named: imgMenu[indexPath.row])\r\n     \r\n        cell.setNeedsLayout()\r\n        return cell\r\n    }\r\n\r\nthis is my VetrinaTableViewCell where I resize image:\r\n\r\nclass VetrinaTableViewCell: UITableViewCell {\r\n\r\n    @IBOutlet weak var ultimoLbl: UILabel!\r\n    @IBOutlet weak var immagineUltimo: UIImageView!\r\n    @IBOutlet weak var numeroCommenti: UILabel!\r\n    \r\n    @IBOutlet weak var likeImg: UIImageView!\r\n    @IBOutlet weak var numeroLike: UILabel!\r\n    @IBOutlet weak var immagineVetrina: UIImageView!\r\n    @IBOutlet weak var nomeuid: UILabel!\r\n    @IBOutlet weak var uidImg: UIImageView!\r\n    \r\n    override func awakeFromNib() {\r\n        super.awakeFromNib()\r\n        // Initialization code\r\n    }\r\n\r\n    override func setSelected(_ selected: Bool, animated: Bool) {\r\n        super.setSelected(selected, animated: animated)\r\n\r\n        // Configure the view for the selected state\r\n    }\r\n\r\n    internal var aspectConstraint : NSLayoutConstraint? {\r\n        didSet {\r\n            if oldValue != nil {\r\n                immagineVetrina.removeConstraint(oldValue!)\r\n            }\r\n            if aspectConstraint != nil {\r\n                immagineVetrina.addConstraint(aspectConstraint!)\r\n            }\r\n        }\r\n    }\r\n    \r\n    override func prepareForReuse() {\r\n        super.prepareForReuse()\r\n        aspectConstraint = nil\r\n    }\r\n    \r\n    func setCustomImage(image : UIImage) {\r\n        \r\n        let aspect = image.size.width / image.size.height\r\n        \r\n        let constraint = NSLayoutConstraint(item: immagineVetrina, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: immagineVetrina, attribute: NSLayoutAttribute.height, multiplier: aspect, constant: 0.0)\r\n        constraint.priority = UILayoutPriority(rawValue: 999)\r\n        \r\n        aspectConstraint = constraint\r\n        \r\n        immagineVetrina.image = image\r\n    }\r\n    \r\n    \r\n}\r\n\r\n\r\n#### Other Comment\r\n\r\n[Add anything else here]\r\n\r\n\r\n<!-- Love Kingfisher? Please consider supporting our collective:\r\n👉  https://opencollective.com/Kingfisher/donate -->\r\n"},"comment":{"url":"https://api.github.com/repos/onevcat/Kingfisher/issues/comments/419066525","html_url":"https://github.com/onevcat/Kingfisher/issues/873#issuecomment-419066525","issue_url":"https://api.github.com/repos/onevcat/Kingfisher/issues/873","id":419066525,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTA2NjUyNQ==","user":{"login":"gorbat-o","id":7542553,"node_id":"MDQ6VXNlcjc1NDI1NTM=","avatar_url":"https://avatars1.githubusercontent.com/u/7542553?v=4","gravatar_id":"","url":"https://api.github.com/users/gorbat-o","html_url":"https://github.com/gorbat-o","followers_url":"https://api.github.com/users/gorbat-o/followers","following_url":"https://api.github.com/users/gorbat-o/following{/other_user}","gists_url":"https://api.github.com/users/gorbat-o/gists{/gist_id}","starred_url":"https://api.github.com/users/gorbat-o/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gorbat-o/subscriptions","organizations_url":"https://api.github.com/users/gorbat-o/orgs","repos_url":"https://api.github.com/users/gorbat-o/repos","events_url":"https://api.github.com/users/gorbat-o/events{/privacy}","received_events_url":"https://api.github.com/users/gorbat-o/received_events","type":"User","site_admin":false},"created_at":"2018-09-06T11:56:16Z","updated_at":"2018-09-06T11:56:16Z","author_association":"NONE","body":"Hello,\r\n\r\nI have the same problem.\r\nAn other point, sometimes I will have an image to load in the cell and sometimes not. \r\nAnd it is the fiesta in the tableview, the cell are not sized correctly, I have to scroll down and scroll up to make appear some images.\r\n\r\nHope you find a solution :)\r\n"}}
{"actor":{"display_login":"gorbat-o"}}