I am creating an app that has 4 views. A homepage, and on this homepage there are 3 buttons, Each goes to one of the remaining three views(a "Play Game" view, a "How to play" view, and a "Settings" view). On the homepage, when I click the buttons that leads to "Settings" view or "How to play" view, The transition is fine, and there is no lag. But, when I click the button that leads to the "Play Game" view, there is lag for 2-3 seconds, and then it goes to the view, and gives me a "Warning: Memory Level=1" warning. I do not know why this is. Could it be that my "Play Game" view has to many things on it? I have 6 buttons, 3 UIImageViews, 4 UILabels, and a UISlider. If this is the problem, could someone please tell me how to fix it without having to take out any of these items? Or if this is not the case, I have provided the Code for Switching Views to PlayGameViewController and the code for the viewDidLoad.
ViewDidLoad:
Code:
-(void)viewDidLoad {
gameState = KGameStateBegin;
/*
NSString *path = [[NSBundle mainBundle] pathForResource:@"GloriousMorning" ofType:@"mp3"];
AVAudioPlayer *theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
//float effects_Volume = [[NSUserDefaults standardUserDefaults] floatForKey:@"effectsVolume"];
//theAudio.volume = effects_Volume;
[theAudio play];
*/
BtnPause.hidden = 1;
[super viewDidLoad];
}
Yea I know, half of it is commented out, because I am not using it Currently.
And here it is for the Switching Views code:
Code:
-(IBAction)goToPlayGame:(id)sender {
PlayGameViewController *view = [[PlayGameViewController alloc] initWithNibName:@"PlayGameViewController" bundle:nil];
[UIView beginAnimations:@"Flipview" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view cache:YES];
[self.view addSubview:view.view];
[UIView commitAnimations];
}
I am pretty sure there is a memory leak in the code above.(If someone could tell me how to fix it that would be great!)
Thanks a bunch!