2011-02-24 28 views

Respuesta

7

establecer un nombre o etiqueta para su Hoja de acción y hacer algo como esta esperanza

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if(actionSheet==yourActionsheet1) 
    { 
     //your logic 
     } 
    if(actionSheet==yourActionsheet2) 
    { 
     //your logic 
     } 
    } 

esta ayuda

+0

Gracias. ¿Sabes cómo configurar los colores de los botones? p.ej. un botón rojo Eliminar? – jarryd

+1

@ Helium3: el color rojo es por defecto el color de los títulos de los botones destructivos en la hoja de acciones. Solo tiene que declarar 'destructiveButtonTitle = @" Delete "' al declarar la hoja de acciones. Espero que esto te ayude. –

+0

Sí, sí, muchas gracias. ;) – jarryd

2

Puede agregar varias hojas de acción al mismo controlador de vista. Puede establecer una etiqueta para cada una de las hojas de acción y verificar la etiqueta en el método de delegado para realizar la función necesaria.

3

Se pueden crear múltiples hojas de acción de la siguiente manera:

actionSheet1 = [[UIActionSheet alloc] initWithTitle:@"Where to go" 
                delegate:self 
              cancelButtonTitle:@"cancel" 
            destructiveButtonTitle:@"Store 2" 
              otherButtonTitles:@"Store 3",@"Store 4",@"Store 5",@"View Store Profile",nil]; 
actionSheet2 = [[UIActionSheet alloc] initWithTitle:@"Where to go" 
                delegate:self 
              cancelButtonTitle:@"cancel" 
            destructiveButtonTitle:@"Store 1" 
              otherButtonTitles:@"Store 3",@"Store 4",@"Store 5",@"View Store Profile",nil]; 
actionSheet3 = [[UIActionSheet alloc] initWithTitle:@"Where to go" 
                delegate:self 
              cancelButtonTitle:@"cancel" 
            destructiveButtonTitle:@"Store 1" 
              otherButtonTitles:@"Store 2",@"Store 4",@"Store 5",@"View Store Profile",nil]; 

& después de eso, compruebe a qué hoja de acción llama el - (void) actionSheet: (UIActionSheet *) actionSheet didDismissWithButtonIndex: (NSInteger) buttonIndex {

if(actionSheet==actionSheet1) 
{ 
} 
else if(actionSheet==actionSheet2) 
{ 
} 
else if(actionSheet==actionSheet3) 
{ 
} 
Cuestiones relacionadas