开发者

How to use EGOImageView with dynamic image sizes?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜