I have a UIView that displays an image depending on how well the user did on a level, then the user has the options to continue to the next level and once they are finished with that one the UIView displays again with an image depending on how well they did
I release the UIView after the user decides they want to go to the next level and inside the UIView I'm pretty sure I release everything once I'm finished with it but when the UIView is loaded for the second time the image from the first time is still there and the second image gets put on top of it so you see both images at the same time.
I'm not sure why this is happening like I said I'm pretty sure I release everything inside the UIView and then I release the UIView when the user is finished with it
I created the UIView with Interface Builder
Any help would be appreciated
//this is the code to access the UIView
-(void)DisplayStatsForLevel:(NSInteger)level ScoreEarned:(NSInteger)pScore NumberHit:(NSInteger)pNumberHit TotalTargets:(NSInteger)pTotalTargets MedalEarned:(NSInteger)pMedalEarned BulletsFired:(NSInteger)pBulletsFired
{
switch(level)
{
case 1:
[levelOne removeFromSuperview];
[levelOne release]; levelOne = nil;
[self.view addSubview:levelComplete];
[levelComplete SetupScreen:pScore NumberHit:pNumberHit TotalTargets:pTotalTargets MedalEarned:pMedalEarned BulletsFired:pBulletsFired];
break;
case 2:
[levelTwo removeFromSuperview];
[levelTwo release]; levelTwo = nil;
[self.view addSubview:levelComplete];
[levelComplete SetupScreen:pScore NumberHit:pNumberHit TotalTargets:pTotalTargets MedalEarned:pMedalEarned BulletsFired:pBulletsFired];
break;
default:
break;
}
}
//this is the code that releases the UIView
-(void)NextLevel:(NSInteger)nextLevel
{
switch (nextLevel)
{
case 2:
[levelComplete removeFromSuperview];
[levelComplete release]; levelComplete = nil;
[self.view addSubview:levelTwo];
[levelTwo SetupLevel];
break;
default:
break;
}
}
//this is the code that displays the image
switch (medalWon)
{
case 1:
medalImage = [UIImage imageNamed:@"Bronze.png"];
break;
case 2:
medalImage = [UIImage imageNamed:@"Silver.png"];
break;
case 3:
medalImage = [UIImage imageNamed:@"Gold.png"];
break;
case 4:
medalImage = [UIImage imageNamed:@"Platinum.png"];
break;
default:
break;
}
medal =[[UIImageView alloc] initWithFrame:medalFrame];
medal.image = medalImage;
[medalImage release];
[medal setNeedsDisplay];
[self addSubview:medal];