在我的游戏中,我使用以下代码以编程方式分配了一些 UIImageViews:
blocks[1] = [[UIImageView alloc] initWithFrame: CGRectMake(200, y1, kBlockHeight, kBlockHeight)];
blocks[2] = [[UIImageView alloc] initWithFrame: CGRectMake(320, y2, kBlockHeight, kBlockHeight)];
blocks[3] = [[UIImageView alloc] initWithFrame: CGRectMake(440, y3, kBlockHeight, kBlockHeight)];
blocks[4] = [[UIImageView alloc] initWithFrame: CGRectMake(560, y4, kBlockHeight, kBlockHeight)];
blocks[1].backgroundColor = [UIColor blackColor];
blocks[2].backgroundColor = [UIColor blackColor];
blocks[3].backgroundColor = [UIColor blackColor];
blocks[4].backgroundColor = [UIColor blackColor];
[self.view addSubview: blocks[1]];
[self.view addSubview: blocks[2]];
[self.view addSubview: blocks[3]];
[self.view addSubview: blocks[4]];
它工作正常,但是当我尝试摆脱对象并重新启动时,
for (int i = 1; i<= 4; i++) {
blocks[i] = nil;
//ARC won't let me call [blocks[i] release];
NSLog(@"releasing blocks");
}
他们仍然留在屏幕上。它们不与任何东西交互,但仍保持在屏幕上绘制。为什么会这样,我应该怎么做才能摆脱这些物体?