I am trying to use two UIAlertViews but both pop up when i trigger one.
-(IBAction)continueGame_button:(id)sender {
//=====CHECK IF THERE IS AN ON-GOING GAME, IF SO CONTINUE=====//
AccessCurrentGameData *isThereAnOngoingGameFunction = [AccessCurrentGameData new];
BOOL ongoingGame = [isThereAnOngoingGameFunction checkIfGameOngoing];
[isThereAnOngoingGameFunction release];
NSLog(@"+ + +continueGame_button+ + +");
NSLog(@"ongoingGame = %@\n", (ongoingGame ? @"YES" : @"NO"));
if (ongoingGame == YES) {
NSLog(@"+++++++++ ONGOING GAME +++++++++");
myAlert = [[UIAlertView alloc] initWithTitle:@"Fortsätta spel"
message:@"Det finns ett aktivt spel, klicka Spela eller Tillbaka"
delegate:self
cancelButtonTitle:@"Tillbaka"
otherButtonTitles:@"Spela", nil];
myAlert.tag=kTagContinueGame;
[myAlert show];
[myAlert release];
}
}
-(IBAction)newGame_button:(id)sender {
myAlert = [[UIAlertView alloc] initWithTitle:@"Varning"
message:@"Om du går vidare kommer pågående spel stoppas och nollställas!"
delegate:self
cancelButtonTitle:@"Tillbaka"
otherButtonTitles:@"Fortsätt", nil];
myAlert.tag=kTagNewGame;
[myAlert show];
myAlert release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
switch(myAlert.tag ) {
case kTagContinueGame:
NSLog(@"kTagContinueGame");
break;
case kTagNewGame:
NSLog(@"kTagNewGame");
AccessCurrentGameData *zeroCurrentGameFileFunction = [AccessCurrentGameData new];
[zeroCurrentGameFileFunction firstCreationOrRestoreOfGameDataFile];
[zeroCurrentGameFileFunction release];
NewGameViewController * temp = [[NewGameViewController alloc] init];
[self setNewGameViewController:temp];
[temp release];
[[self navigationController] pushViewController:newGameViewController animated:YES];
break;
default:
break;
}
开发者_如何学Go}
Check your IBOutlet. You may have 1 button that is connected to 2 of your IBAction's.
If it's a UIButton, check the touchUpInside
.
精彩评论