Múltiplas UIActionSheets no mesmo delegado
Estou escrevendo um jogo de quebra-cabeça. Quando o usuário pressiona o botão de verificação, vejo se a solução inserida está correta. Dependendo do resultado, apresento uma das duas folhas de ação para eles. Por enquanto, só tenho algumas instruções do NSLog para garantir que as coisas sejam chamadas, mas apenas uma das planilhas parece funcionar corretament
Nada é chamada quando clico em um botão no showErrorsActionSheet. A folha de ação desaparece da tela, mas os logs nunca são impresso
Suspeito que tenha algo a ver com a declaração de duas planilhas de ações para o mesmo delegado (auto)
- (void) checkSolution {
//code determines the value of the BOOL allCorrect
if (allCorrect) { //IF ALL OF THE LETTERS WERE CORRECT
//display UIAlertView;
NSLog(@"allCorrect");
UIActionSheet *levelCompleteActionSheet = [[UIActionSheet alloc] initWithTitle:@"Congratulations! You Have Finished the Level!" delegate:self cancelButtonTitle:@"Review my work" destructiveButtonTitle:@"Choose next puzzle" otherButtonTitles:nil, nil];
[levelCompleteActionSheet showInView:self.view];
[levelCompleteActionSheet release];
}
else {
//[self showIncorrectLettersInRed];
UIActionSheet *showErrorsActionSheet = [[UIActionSheet alloc] initWithTitle:@"Sorry, thats not right. Show errors in red?" delegate:self cancelButtonTitle:@"No Thanks, I'll keep trying" destructiveButtonTitle:@"Yes please, I'm stuck!" otherButtonTitles:nil, nil];
[showErrorsActionSheet showInView:self.view];
[showErrorsActionSheet release];
}
}
os métodos que devem ser chamados são:
- (void) levelCompleteActionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [actionSheet cancelButtonIndex]) {
NSLog(@"return to levelSelect");
//pushViewController:levelSelect
}
else {
NSLog(@"continue to examine solution");
}
}
- (void) showErrorsActionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [actionSheet cancelButtonIndex]) {
NSLog(@"show errors in red");
}
else {
NSLog(@"continue to try");
}
}
e eu declarei o protocolo UIActionSheet no arquivo de interface da seguinte maneira:
@interface GamePlay : UIViewController <UIActionSheetDelegate> {