2012-02-29 3 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]; 

당신이 아이폰 앱 사용을 위해 UIActionSheet showInView 방법을 사용하는 경우 -

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

예 -

[actionSheet showInView:self.view.window]; 
관련 문제