Open sharpfive opened 9 years ago
There are explicit asserts in the resizing code.
Format.resizeImage
We have to set the scale mode to none, but I cant seem to find out how to.
Read hpique response on #95. I was able to get it working with imageView.setImageFromURL(URL, format: Format<UIImage>("original"))
, but when trying to use the closure to resize (the first example) I got some error I can't remember now.
Why does it have to do an assert by default, causing the app the crash? Why not fall back to loading the full sized image? In my opinion, this shouldn't be a fatal error. I ended up writing an extension that falls back to full size if the image view has a zero size:
import Haneke
import UIKit
extension UIImageView {
func hnk_setImageFromURLAutoSize(url: NSURL) {
var format: Format<UIImage>? = nil
if frame.size == CGSize.zero {
format = Format<UIImage>(name: "original")
}
hnk_setImageFromURL(url, format: format)
}
}
Crash happens after the downloading an image for the first time.
logoImage.frame = CGRectZero logoImage.hnk_setImageFromURL(logoImageURL)
Crash happens in: Haneke.ImageResizer.resizeImage
Subsequent calls to set_ImageFromURL do not crash if the image has been downloaded and resized previously.
Installed via Carthage github "Haneke/HanekeSwift" "v0.8.1"