2011-12-18 6 views
12

Tengo una UIActionSheet y estoy especificando el botón cancelar sin embargo, no se cierra cuando se toca?Botón de cancelación de UIActionSheet que no descarta la hoja de acciones

UIActionSheet *actionSheet = [[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Target Complete" otherButtonTitles:nil] autorelease]; 
[actionSheet showInView:self.view]; 

De acuerdo con la documentación que no necesito ningún código e incluso cuando intento y poner en práctica el método delegado didCancel su nunca se llama?

Respuesta

3

Debe mostrar desde una barra de tareas o una barra de herramientas en el iPhone, ya que recorta algunos de los controles si utiliza la visualización en la vista.

42

Prueba este

[actionSheet showInView:[self.view window]]; 

UIActionSheet cancel button strange behaviour

+1

Esta debe ser la respuesta aceptada. –

+0

@nevan king: Esto no es trabajo para mí, entonces no utilicé ninguna tabbar o barra de tareas. Estoy usando la navegación, ¿cómo puedo descartar con el botón Cancelar? – TamilKing

14

esto va a hacer el truco

[actionSheet showInView:[self.view window]]; 

en lugar de

[actionSheet showInView:self.view]; 
0

código SimpLite escritura

actionSheet.actionSheetStyle = UIActionSheetStyleDefault; 

este trabajo bien

4

uso

[actionSheet showFromTabBar:[[self tabBarController] tabBar]]; 

en lugar de

[actionSheet showInView:self.view]; 

esto está funcionando bien .. :-)

Cuestiones relacionadas