2012-02-29 38 views
8

Ho utilizzato il codice dal post this per visualizzare un foglio di azione nella mia applicazione. Ma mostra comeUIActionSheet iPad non visualizzato

enter image description here

Quale sarà il motivo?

Il mio codice per visualizzare foglio di azione sia

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

Atleast dare qualche titolo ai pulsanti. Altrimenti non verrà visualizzato. –

risposta

0

Utilizzare il metodo UIActionSheet showFromRect o UIActionSheet showFromBarButtonItem:.

UIActionSheetDelegate metodi sono -

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

esempio:

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

Se si sta utilizzando per iPhone uso app UIActionSheet showInView metodo -

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

esempio -

[actionSheet showInView:self.view.window];