iPad UIActionSheet没有显示

rak*_*hNS 8 iphone cocoa-touch uiactionsheet

我使用这篇文章中的代码在我的应用程序中显示一个操作表.但它表现得像

在此输入图像描述

会是什么原因?

我显示操作表的代码是

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];
Run Code Online (Sandbox Code Playgroud)

aVi*_*aSh 9

更换

 [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
Run Code Online (Sandbox Code Playgroud)

 [actionSheet showFromRect:btnShare.frame inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)

或者如果你想在iPad上使用动作表,那么试试这个自定义控件 https://nodeload.github.com/Arrived/BlockAlertsAnd-ActionSheets/zipball/master