2012-02-29 13 views
8

私はthisポストのコードを使用してアプリケーションにアクションシートを表示しました。しかし、それは理由になります何iPad UIActionSheetが表示されない

enter image description here

のように示していますか?

アクションシートを表示するために私のコードは

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

ボタンにいくつかタイトルを付けてください。それ以外の場合は表示されません。 –

答えて

0

UIActionSheet showFromRectまたはUIActionSheet showFromBarButtonItem:メソッドを使用してください。

UIActionSheetDelegateの方法がある -

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

例:

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

あなたがiPhoneアプリを使用するためUIActionSheet showInView方法を使用している場合 -

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

例 -

[actionSheet showInView:self.view.window]; 
関連する問題