2012-02-29 17 views
8

Utilicé el código de la publicación this para mostrar una hoja de acción en mi aplicación. Pero muestra comoiPad UIActionSheet no muestra

enter image description here

¿Cuál será la razón?

Mi código para mostrar la hoja de acción es

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                 delegate:nil 
               cancelButtonTitle:nil 
              destructiveButtonTitle:nil 
               otherButtonTitles:nil]; 

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; 

CGRect pickerFrame = CGRectMake(0, 40, 300, 300); 

UIView *pickerView = [[UIView alloc] initWithFrame:pickerFrame]; 
pickerView.backgroundColor=[UIColor blackColor]; 

[actionSheet addSubview:pickerView]; 


UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]]; 
closeButton.momentary = YES; 
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f); 
closeButton.segmentedControlStyle = UISegmentedControlStyleBar; 
closeButton.tintColor = [UIColor blackColor]; 
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged]; 
[actionSheet addSubview:closeButton]; 


[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]]; 

[actionSheet setBounds:CGRectMake(0, 0, 320, 485)]; 

[self.view addSubview:actionSheet]; 
+0

Por lo menos, conceda un título a los botones. De lo contrario, no aparecerá. –

Respuesta

0

Utilice UIActionSheet showFromRect o UIActionSheet showFromBarButtonItem: método.

UIActionSheetDelegate métodos son -

- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated; 
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated; 

ejemplo:

[actionSheet showFromRect:self.btnShare.frame inView:self.view animated:YES]; 

Si está utilizando para el uso de aplicaciones iPhone UIActionSheet showInView método -

- (void)showInView:(UIView *)view; 

ejemplo -

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