开发者

How to use EGOImageView with dynamic image sizes?

开发者 https://www.devze.com 2023-03-27 23:44 出处:网络
I am using EGOImageView from Enormego (github here) and was wondering if anyone had successfully implemented this (along with the caching provided by EGOCache) with different size images. I can only g

I am using EGOImageView from Enormego (github here) and was wondering if anyone had successfully implemented this (along with the caching provided by EGOCache) with different size images. I can only get it to work with a static image size and it goes a bi开发者_运维技巧t haywire if I try to resize the image view after its finished loading or etc. Anyone got any ideas/bits of wisdom? I believe it's somewhere in the EGOImageLoader code but the blocks portion is a bit over my head.


For anyone who might run across this problem, I modified the imageLoaderDidLoad: method of EGOImageView to this:

- (void)imageLoaderDidLoad:(NSNotification*)notification {
    UIImage* anImage = [[notification userInfo] objectForKey:@"image"];
    if(anImage) {
        self.image = anImage;
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.image.size.width, self.image.size.height);
    } else {
        self.image = self.placeholderImage;
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.image.size.width, self.image.size.height);
    }
    [self setNeedsDisplay];

    if([self.delegate respondsToSelector:@selector(imageViewLoadedImage:)]) {
        [self.delegate imageViewLoadedImage:self];
    }   
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号