Soo
Soo

Reputation: 397

iOS removeFromSuperview and zoom

I add multiple images and show them with zoom. Due to limited memory size, I should try to remove some of them which has already seen with removeFromSuperview. My problem is that when I try to zoom, selected image is disappeared by removeFromSuperview.

My codes are as below:

if ( [contentView viewWithTag:CONTENT_IMAGE_TAG_NUM + index] ) {
    if (index > 2) {
        UIView *prevContentView = [contentView viewWithTag:(CONTENT_IMAGE_TAG_NUM + index - 2)];
        if (prevContentView) {
            [prevContentView removeFromSuperview];
            [[SDImageCache sharedImageCache] clearMemory];
        }
    }
} else {
    UIImageView *imageView = [self addContentImage:index contentArray:contentArray prevImageHeight:prevImageHeight];
-----

}

When I try to zoom at 3rd image, it is disappeared. To solve zoom problem, I removed 'removeFromSuperview' and could zoom well. But it made memory problem. I got memory warning. How can I solve this problem? I want to fix both zoom and memory issue. Please let me know. Thanks in advance.

Upvotes: 0

Views: 80

Answers (1)

pronebird
pronebird

Reputation: 12230

Cells are reused in table views and collection views, so you do not have to bother much about memory since the image view that you use will switch its image and therefore release previously retained image. SDImageCache on the other side should flush memory cache when memory warning received. So I guess you have a problem somewhere else.

Upvotes: 1

Related Questions