views:

291

answers:

1

I have a layer in my game. At finishing of game I want to show user an UIAlertView for restarting or quitting the game. But it is not working. I am also given the delegate UIAlertViewDelegate to layer.

Any Solutions?

My Code follows,

-(void)gameFinished{ [[UIApplication sharedApplication] setIdleTimerDisabled:NO];

[self unschedule:@selector(checkForCollision)]; [self unschedule:@selector(dropObject)]; [self stopBackgroundMusic];

[self startNewForegroundMusic:@"GameOver" ofType:@"caf"]; [self playForegroundMusic];

[[Director sharedDirector] pause]; UIAlertView *view=[[UIAlertView alloc] initWithTitle:@"Game Finished" message:@"Want to play again?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes"]; [view show]; [view release]; }

A: 

Does your code crash, or does it just not display?

You do have a slight error in the line

[[UIAlertView alloc] initWithTitle:@"Game Finished"
                     message:@"Want to play again?"
                     delegate:self cancelButtonTitle:@"No"
                     otherButtonTitles:@"Yes"]

This should be

[[UIAlertView alloc] initWithTitle:@"Game Finished"
                     message:@"Want to play again?"
                     delegate:self cancelButtonTitle:@"No"
                     otherButtonTitles:@"Yes", Nil]

note: the last parameter is variable argument, and thus should be Nil terminated.

nash
Hey Nash,Thanks a lot. Its worked.
Jay