AVISO: Cualquier pregunta que no cumpla ninguno de estos criterios podrá ser borrada sin previo aviso.

Resulta que estoy haciendo una app con múltiples ActionSheet, cuando introduje una me iba genial, pero al introducir dos me da un problema. Click para foto

Aqui va el código:

-(IBAction)wannaZeroEng:(id)sender{
    UIActionSheet *actionSheet;
    actionSheet=[[UIActionSheet alloc] initWithTitle:@"Are you sure you want to reset the counter?"
        delegate:self
        cancelButtonTitle:@"No"
        destructiveButtonTitle:@"Yes. Reset."
        otherButtonTitles:nil];
    [actionSheet showInView:self.view];
    [actionSheet release];

}

-(void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *buttonTitle=[actionSheet buttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"Yes. Reset."]) {
        counter=0;
    count.text = [NSString stringWithFormat:@"%i",counter];
    }
}

Y luego en español:

-(IBAction)wannaZeroSpa:(id)sender{    
    UIActionSheet *actionSheet;
    actionSheet=[[UIActionSheet alloc] initWithTitle:@"¿Estas seguro de querer reiniciar el contador?"
        delegate:self
        cancelButtonTitle:@"No"
        destructiveButtonTitle:@"Reiniciar"
        otherButtonTitles:nil];
    [actionSheet showInView:self.view];
    [actionSheet release];

}

-(void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSString *buttonTitle=[actionSheet buttonTitleAtIndex:buttonIndex];
    if ([buttonTitle isEqualToString:@"Reiniciar"]) {
        counter=0;
        count.text = [NSString stringWithFormat:@"%i",counter];
    }
}

Creo que el problema viene dado porque me coincide el nombre que le doy al actionSheet en la de inglés y la española.

P.D: Se encuentran en la misma clase. En TapCounterViewController.m

preguntado 15 Oct '11, 19:58

alexperezpaya's gravatar image

alexperezpaya
174510

editó 15 Oct '11, 20:00


SI , el problema esta en que tienes dos veces definida la misma funcion.

Pero realmente creo que debrias abordar el problema de otra manera.

Si se trata de idiomas diferentes solo , create un fichero de textos localizados y usa usa

NSLocalizedString(@"Reiniciar", @"texto_reinicio");

Si el tema va mas alla de solo idiomas , usa una misma funcion , pero identifica los actionSheet mediante tags por ejemplo.

actionSheet1.tag = 0;
actionSheet2.tag = 1;

luego

-(void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
  switch(actionSheet.tag){
        case 0:
//codigo para actionSheet1
break;
        case 1:
//codigo actionSheet2
break;
        default:
break;
    }
}
enlace permanente

respondido 15 Oct '11, 20:31

StaS's gravatar image

StaS
5.1k953

El problema es que no solo es cosa de idiomas, sino hubiese creado varias localizaciones, que ahora lo haré, pero la cosa es que además de esas quiero tener otras actionsheet que tienen otra función. Ahh por cierto StaS muchas gracias que me estas ayudando un monton con la app

(15 Oct '11, 20:46) alexperezpaya

y si utilizo varias localizaciones y me quito el problema del idioma y paso a meter dos actionsheet con diferentes definiciones. Una para el reset, y otra para los enlaces externos?

(15 Oct '11, 20:50) alexperezpaya
Tu respuesta:
Activar/desactivar vista previa

Sobre esta pregunta

Etiquetas de la pregunta:

×245
×10
×1

Pregunta realizada el: 15 Oct '11, 19:58

Pregunta visitada: 565 veces

Última modificación: 15 Oct '11, 20:50

Seguir esta pregunta

Por Email:

Una vez que entres podrás suscribirte desde aquí para recibir actualizaciones

Por RSS:

Respuestas

Respuestas y Comentarios

Realizar Donación