嗨,我的程序將小圖像添加到主視圖。我有這個撤消按鈕來刪除最近添加的圖像(子視圖)。當它具有所有不同的圖像時它工作正常,但是當有兩個相同的圖像時,它會發生錯誤。 我認爲這是因爲它都指向相同的原始PNG文件。但我不知道如何解決它。請給我一些提示。如何分配相同類型的分類內存空間
add{
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"pah%d",tagNum]];
TouchImageView *touchImageView = [[TouchImageView alloc] initWithFrame:imageRect];
imageCounter++;
touchImageView.tag = imageCounter;
touchImageView.image = image;
touchImageView.center = CGPointMake(160.0, 230.0);
[view addSubview:touchImageView];
}
undo{
[[self.view viewWithTag:imageCounter] removeFromSuperview];
imageCounter--;
}
這表明奇怪的錯誤。就在我上面的代碼之前,我將mainview添加到屏幕上,例如「[self.view insertSubview:photoViewCon.view atIndex:0];」。在第二次嘗試添加圖像之後,它會凍結該點。 – user842589