0
我正在生成一个简单的scrollView,其中一些图像附加到按钮上。 这个工作很好,除了这个滚动视图占用了很多内存。当前从多个图像的UIScrollview释放内存的方式
因为这个scrollView只是一个子菜单,允许用户选择一个图像,不久之后我不需要它,我想从内存中释放这个沉重的块。
你能好心帮助我理解这个问题,并免费在不需要时
int flipFlop = 1;
masksAvailable = 18;
float topMaskXX = 85.0;
float topMaskYY = 96.0;
UIButton *button;
for (int buttonsLoop = 1;buttonsLoop < masksAvailable+1;buttonsLoop++){
button = [UIButton buttonWithType:UIButtonTypeCustom];
NSString *tempname = [NSString stringWithFormat:@"mask_frame%i.png",buttonsLoop];
// This fellow there is the memory eating monster
[button setBackgroundImage:[UIImage imageNamed:tempname] forState:UIControlStateNormal];
tempname = nil;
button.tag = buttonsLoop;
[button addTarget:self action:@selector(handleMaskKeys:) forControlEvents:UIControlEventTouchUpInside];
UIImageView *frameForSubImages = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_frame.png"]];
frameForSubImages.frame = CGRectMake(0.0, 0.0, 320.0/2.9, 480.0/2.9);
frameForSubImages.center = CGPointMake(topMaskXX,topMaskYY);
[scrollView addSubview:frameForSubImages];
button.frame = CGRectMake(0.0, 0.0, 320.0/3.4, 480.0/3.4);
button.center = CGPointMake(topMaskXX,topMaskYY);
if (flipFlop == 1){
topMaskXX += 150;
} else {
topMaskYY += 185.0;
topMaskXX = 85.0;
}
flipFlop = flipFlop * -1;
[scrollView addSubview:button];
}